Gmedia Photo Gallery - Version 1.8.10

Version Description

  • Added: Stack for Gmedia Items
  • New: Selected items now cleared automatically after Action
  • Changed: Numeric title from EXIF will be saved to DB
Download this release

Release Info

Developer pasyuk
Plugin Icon 128x128 Gmedia Photo Gallery
Version 1.8.10
Comparing to
See all releases

Code changes from version 1.7.56 to 1.8.10

Files changed (191) hide show
  1. admin/addmedia/functions.php +0 -7
  2. admin/admin.php +145 -159
  3. admin/ajax.php +168 -67
  4. admin/app.php +44 -50
  5. admin/assets/css/gmedia.admin.css +1254 -0
  6. admin/{css → assets/css}/gmedia.metabox.css +0 -0
  7. admin/{img → assets/img}/application.png +0 -0
  8. admin/{img → assets/img}/appstore_button.png +0 -0
  9. admin/{img → assets/img}/archive.png +0 -0
  10. admin/{img → assets/img}/audio.png +0 -0
  11. admin/{img → assets/img}/blank.gif +0 -0
  12. admin/{img → assets/img}/clicked.png +0 -0
  13. admin/{img → assets/img}/code.png +0 -0
  14. admin/{img → assets/img}/default.png +0 -0
  15. admin/{img → assets/img}/document.png +0 -0
  16. admin/{img → assets/img}/gm-icon.png +0 -0
  17. admin/{img → assets/img}/grand_icon.png +0 -0
  18. admin/{img → assets/img}/icon.png +0 -0
  19. admin/{img → assets/img}/icon_edit.png +0 -0
  20. admin/{img → assets/img}/interactive.png +0 -0
  21. admin/{img → assets/img}/loading.gif +0 -0
  22. admin/{img → assets/img}/metabox.png +0 -0
  23. admin/{img → assets/img}/mobile_app.png +0 -0
  24. admin/{img → assets/img}/refresh.png +0 -0
  25. admin/{img → assets/img}/reload.png +0 -0
  26. admin/{img → assets/img}/social-footer.png +0 -0
  27. admin/{img → assets/img}/spreadsheet.png +0 -0
  28. admin/{img → assets/img}/text.png +0 -0
  29. admin/{img → assets/img}/throbber.gif +0 -0
  30. admin/{img → assets/img}/video.png +0 -0
  31. admin/{js → assets/js}/gmedia.admin.js +204 -7
  32. admin/{js → assets/js}/gmedia.global.js +2 -2
  33. admin/{js → assets/js}/gmedia.metabox.js +3 -3
  34. admin/class.processor.php +53 -24
  35. admin/css/gmedia.admin.css +0 -1246
  36. admin/galleries.php +75 -61
  37. admin/modules.php +0 -209
  38. admin/{addmedia → pages/addmedia}/addmedia.php +4 -7
  39. admin/{addmedia → pages/addmedia}/tpl/assign-terms.php +0 -0
  40. admin/{addmedia → pages/addmedia}/tpl/import.php +1 -1
  41. admin/{addmedia → pages/addmedia}/tpl/panel-heading.php +0 -0
  42. admin/{addmedia → pages/addmedia}/tpl/upload.php +2 -2
  43. admin/{library → pages/library}/functions.php +10 -16
  44. admin/{library → pages/library}/library.php +34 -9
  45. admin/{library → pages/library}/tpl/edit-item.php +28 -12
  46. admin/{library → pages/library}/tpl/grid-item.php +12 -4
  47. admin/{library → pages/library}/tpl/list-item.php +21 -8
  48. admin/{library/tpl/no-item.php → pages/library/tpl/no-items.php} +0 -0
  49. admin/{library → pages/library}/tpl/panel-footer.php +0 -0
  50. admin/{library → pages/library}/tpl/panel-heading.php +42 -22
  51. admin/pages/modules/functions.php +125 -0
  52. admin/pages/modules/modules.php +72 -0
  53. admin/pages/modules/tpl/modal-modulezip.php +26 -0
  54. admin/pages/modules/tpl/module-item.php +26 -0
  55. admin/pages/settings/settings.php +70 -0
  56. admin/pages/settings/tpl/common.php +106 -0
  57. admin/pages/settings/tpl/license.php +30 -0
  58. admin/pages/settings/tpl/permalinks.php +182 -0
  59. admin/pages/settings/tpl/roles.php +123 -0
  60. admin/pages/settings/tpl/system.php +33 -0
  61. admin/pages/taxonomy/edit-album.php +46 -0
  62. admin/pages/taxonomy/edit-filter.php +222 -0
  63. admin/pages/taxonomy/functions.php +194 -0
  64. admin/pages/taxonomy/terms.php +991 -0
  65. admin/pages/taxonomy/tpl/album-create-item.php +80 -0
  66. admin/pages/taxonomy/tpl/album-edit-item.php +129 -0
  67. admin/pages/taxonomy/tpl/album-list-item.php +43 -0
  68. admin/pages/taxonomy/tpl/album-sort-gmedia.php +188 -0
  69. admin/pages/taxonomy/tpl/category-list-item.php +23 -0
  70. admin/pages/taxonomy/tpl/filter-edit-item.php +420 -0
  71. admin/pages/taxonomy/tpl/filter-list-item.php +48 -0
  72. admin/pages/taxonomy/tpl/no-items.php +11 -0
  73. admin/pages/taxonomy/tpl/tag-create-item.php +27 -0
  74. admin/pages/taxonomy/tpl/tag-list-item.php +32 -0
  75. admin/pages/taxonomy/tpl/term-panel-heading.php +42 -0
  76. admin/pages/taxonomy/tpl/terms-create-alert.php +10 -0
  77. admin/pages/taxonomy/tpl/terms-panel-heading.php +122 -0
  78. admin/{class.processor.addmedia.php → processor/class.processor.addmedia.php} +0 -0
  79. admin/{class.processor.galleries.php → processor/class.processor.galleries.php} +0 -0
  80. admin/{class.processor.library.php → processor/class.processor.library.php} +58 -19
  81. admin/{class.processor.modules.php → processor/class.processor.modules.php} +21 -6
  82. admin/{class.processor.settings.php → processor/class.processor.settings.php} +14 -2
  83. admin/{class.processor.terms.php → processor/class.processor.terms.php} +83 -8
  84. admin/{class.processor.wpmedia.php → processor/class.processor.wpmedia.php} +2 -1
  85. admin/settings.php +0 -435
  86. admin/terms.php +0 -1844
  87. admin/tpl/comments.php +59 -0
  88. admin/tpl/modal-share.php +25 -5
  89. admin/tpl/search-form.php +2 -1
  90. admin/wpmedia.php +1 -1
  91. app/access.php +425 -287
  92. assets/fancybox/images/blank.gif +0 -0
  93. assets/fancybox/images/fancy_shadow_e.png +0 -0
  94. assets/fancybox/images/fancy_shadow_ne.png +0 -0
  95. assets/fancybox/images/fancy_shadow_nw.png +0 -0
  96. assets/fancybox/images/fancy_shadow_se.png +0 -0
  97. assets/fancybox/images/fancy_shadow_sw.png +0 -0
  98. assets/fancybox/images/fancy_title_left.png +0 -0
  99. assets/fancybox/images/fancy_title_main.png +0 -0
  100. assets/fancybox/images/fancy_title_right.png +0 -0
  101. assets/fancybox/images/fancybox-x.png +0 -0
  102. assets/fancybox/images/fancybox.png +0 -0
  103. assets/fancybox/jquery.fancybox-1.3.4.css +0 -0
  104. assets/fancybox/jquery.fancybox-1.3.4.pack.js +0 -0
  105. assets/gmedia.global.front.js +2 -2
  106. assets/icons/favicon.png +0 -0
  107. assets/image-editor/image-editor.js +0 -0
  108. assets/image-editor/img/loader.gif +0 -0
  109. assets/image-editor/img/minus_plus.png +0 -0
  110. assets/image-editor/img/slider_bg.png +0 -0
  111. assets/image-editor/style.css +0 -0
  112. assets/jq-plugins/jquery.easing.js +0 -0
  113. assets/jq-plugins/jquery.tool.tabs.min.js +0 -0
  114. assets/jq-plugins/outside-events.js +0 -0
  115. assets/jqueryFileTree/images/directory.png +0 -0
  116. assets/jqueryFileTree/images/folder_open.png +0 -0
  117. assets/jqueryFileTree/images/spinner.gif +0 -0
  118. assets/jqueryFileTree/jqueryFileTree.css +0 -0
  119. assets/jqueryFileTree/jqueryFileTree.js +0 -0
  120. assets/mag-popup/LICENSE.txt +20 -0
  121. assets/mag-popup/jquery.magnific-popup.min.js +4 -0
  122. assets/mag-popup/magnific-popup.css +353 -0
  123. assets/mediaelement/bigplay.svg +0 -0
  124. assets/mediaelement/controls.svg +0 -0
  125. assets/mediaelement/flashmediaelement.swf +0 -0
  126. assets/mediaelement/loading.gif +0 -0
  127. assets/mediaelement/mediaelement-and-player.min.js +0 -0
  128. assets/mediaelement/mediaelementplayer.min.css +0 -0
  129. assets/mediaelement/silverlightmediaelement.xap +0 -0
  130. assets/mousetrap/mousetrap.min.js +0 -0
  131. assets/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css +0 -0
  132. assets/plupload/jquery.plupload.queue/img/backgrounds.gif +0 -0
  133. assets/plupload/jquery.plupload.queue/img/delete.gif +0 -0
  134. assets/plupload/jquery.plupload.queue/img/done.gif +0 -0
  135. assets/plupload/jquery.plupload.queue/img/error.gif +0 -0
  136. assets/plupload/jquery.plupload.queue/img/throbber.gif +0 -0
  137. assets/plupload/jquery.plupload.queue/jquery.plupload.queue.js +0 -0
  138. assets/plupload/license.txt +0 -0
  139. assets/plupload/plupload.flash.js +0 -0
  140. assets/plupload/plupload.flash.swf +0 -0
  141. assets/plupload/plupload.html4.js +0 -0
  142. assets/plupload/plupload.html5.js +0 -0
  143. assets/plupload/plupload.js +0 -0
  144. assets/swf/swfaddress.js +0 -0
  145. assets/swf/swfobject.js +0 -0
  146. config/setup.php +64 -42
  147. config/update.php +381 -162
  148. grand-media.php +184 -39
  149. inc/core.php +130 -59
  150. inc/db.connect.php +342 -120
  151. inc/expressInstall.swf +0 -0
  152. inc/frontend.filters.php +86 -0
  153. inc/hashids.php +5 -1
  154. inc/media-upload.php +15 -13
  155. inc/permalinks.php +92 -2
  156. inc/post-metabox.php +6 -6
  157. inc/shortcodes.php +2 -2
  158. load-template.php +2 -1
  159. module/afflux/gallery.swf +0 -0
  160. module/afflux/img/loader.gif +0 -0
  161. module/afflux/index.php +1 -1
  162. module/afflux/js/jquery.gmAfflux.js +1 -1
  163. module/afflux/settings.php +1 -1
  164. module/jq-mplayer/img/button-bg.png +0 -0
  165. module/jq-mplayer/img/player-bg.png +0 -0
  166. module/jq-mplayer/img/player-next-hover.png +0 -0
  167. module/jq-mplayer/img/player-next.png +0 -0
  168. module/jq-mplayer/img/player-pause-hover.png +0 -0
  169. module/jq-mplayer/img/player-pause.png +0 -0
  170. module/jq-mplayer/img/player-previous-hover.png +0 -0
  171. module/jq-mplayer/img/player-previous.png +0 -0
  172. module/jq-mplayer/img/player-progress.png +0 -0
  173. module/jq-mplayer/img/rating-bar-on.png +0 -0
  174. module/jq-mplayer/img/rating-bar.png +0 -0
  175. module/jq-mplayer/img/rating-on.png +0 -0
  176. module/jq-mplayer/img/tracklist-bg.png +0 -0
  177. module/jq-mplayer/img/tracklist-more.png +0 -0
  178. module/minima/gallery.swf +0 -0
  179. module/minima/img/loader.gif +0 -0
  180. module/phantom/css/style.css +578 -391
  181. module/phantom/img/LightboxLoader.gif +0 -0
  182. module/phantom/img/ThumbnailLoader.gif +0 -0
  183. module/phantom/img/facebook@2x.png +0 -0
  184. module/phantom/img/google@2x.png +0 -0
  185. module/phantom/img/loader.gif +0 -0
  186. module/phantom/img/pinterest@2x.png +0 -0
  187. module/phantom/img/stumbleupon@2x.png +0 -0
  188. module/phantom/img/twitter@2x.png +0 -0
  189. module/phantom/index.php +3 -3
  190. module/phantom/init.php +236 -51
  191. module/phantom/js/jquery.gmPhantom.js +715 -973
admin/addmedia/functions.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: rattus
5
- * Date: 15.12.16
6
- * Time: 14:12
7
- */
 
 
 
 
 
 
 
admin/admin.php CHANGED
@@ -4,17 +4,17 @@
4
  * GmediaAdmin - Admin Section for GRAND Media
5
  *
6
  */
7
- class GmediaAdmin
8
- {
9
  var $pages = array();
10
 
11
  /**
12
  * constructor
13
  */
14
- function __construct()
15
- {
16
  global $pagenow;
17
 
 
 
18
  // Add the admin menu
19
  add_action('admin_menu', array(&$this, 'add_menu'));
20
 
@@ -35,8 +35,7 @@ class GmediaAdmin
35
  /**
36
  * Load gmedia pages in wpless interface
37
  */
38
- function gmedia_blank_page()
39
- {
40
  set_current_screen('GrandMedia_Settings');
41
 
42
  global $gmCore;
@@ -46,24 +45,27 @@ class GmediaAdmin
46
  $gmediablank = isset($_GET['gmediablank'])? $_GET['gmediablank'] : '';
47
  return "gmedia-blank $gmediablank"; });
48
  */
49
- add_filter('admin_body_class', create_function('', '$gmediablank = isset($_GET["gmediablank"])? $_GET["gmediablank"] : ""; return "gmedia-blank $gmediablank";'));
50
  define('IFRAME_REQUEST', true);
51
 
52
  iframe_header('GmediaGallery');
53
 
54
- switch ($gmediablank) {
55
  case 'update_plugin':
56
  require_once(dirname(dirname(__FILE__)) . '/config/update.php');
57
  gmedia_do_update();
58
- break;
59
  case 'image_editor':
60
  require_once(dirname(dirname(__FILE__)) . '/inc/image-editor.php');
61
  gmedia_image_editor();
62
- break;
63
  case 'map_editor':
64
  require_once(dirname(dirname(__FILE__)) . '/inc/map-editor.php');
65
  gmedia_map_editor();
66
- break;
 
 
 
67
  }
68
 
69
  iframe_footer();
@@ -73,29 +75,27 @@ class GmediaAdmin
73
  /**
74
  * @return string
75
  */
76
- function gmedia_blank_page_body_class()
77
- {
78
  return 'gmedia-blank';
79
  }
80
 
81
  // integrate the menu
82
- function add_menu()
83
- {
84
  $gmediaURL = plugins_url(GMEDIA_FOLDER);
85
  $this->pages = array();
86
- $this->pages[] = add_object_page(__('Gmedia Library', 'grand-media'), 'Gmedia Gallery', 'gmedia_library', 'GrandMedia', array( &$this, 'shell'), $gmediaURL . '/admin/img/gm-icon.png');
87
- $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Library', 'grand-media'), __('Gmedia Library', 'grand-media'), 'gmedia_library', 'GrandMedia', array( &$this, 'shell'));
88
- if (current_user_can('gmedia_library')) {
89
- $this->pages[] = add_submenu_page('GrandMedia', __('Add Media Files', 'grand-media'), __('Add/Import Files', 'grand-media'), 'gmedia_upload', 'GrandMedia_AddMedia', array( &$this, 'shell'));
90
- $this->pages[] = add_submenu_page('GrandMedia', __('Albums, Tags, Filters...', 'grand-media'), __('Albums, Tags, Filters...', 'grand-media'), 'gmedia_library', 'GrandMedia_Terms', array( &$this, 'shell'));
91
- $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Galleries', 'grand-media'), __('Create/Manage Galleries...', 'grand-media'), 'gmedia_gallery_manage', 'GrandMedia_Galleries', array( &$this, 'shell'));
92
- $this->pages[] = add_submenu_page('GrandMedia', __('Modules', 'grand-media'), __('Modules', 'grand-media'), 'gmedia_gallery_manage', 'GrandMedia_Modules', array( &$this, 'shell'));
93
- $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Settings', 'grand-media'), __('Settings', 'grand-media'), 'manage_options', 'GrandMedia_Settings', array( &$this, 'shell'));
94
- $this->pages[] = add_submenu_page('GrandMedia', __('Mobile Application', 'grand-media'), __('Mobile Application', 'grand-media'), 'gmedia_settings', 'GrandMedia_App', array( &$this, 'shell'));
95
- $this->pages[] = add_submenu_page('GrandMedia', __('Wordpress Media Library', 'grand-media'), __('WP Media Library', 'grand-media'), 'gmedia_import', 'GrandMedia_WordpressLibrary', array( &$this, 'shell'));
96
  }
97
 
98
- foreach ($this->pages as $page) {
99
  add_action("load-$page", array(&$this, 'screen_help'));
100
  }
101
  }
@@ -104,27 +104,23 @@ class GmediaAdmin
104
  * Load the script for the defined page and load only this code
105
  * Display shell of plugin
106
  */
107
- function shell()
108
- {
109
- global $gmProcessor, $gmGallery;
 
110
 
111
  // check for upgrade
112
- if (get_option('gmediaDbVersion') != GMEDIA_DBVERSION) {
113
- if (isset($_GET['do_update']) && ('gmedia' == $_GET['do_update'])) {
114
- $update_frame = '<iframe name="gmedia_update" id="gmedia_update" width="100%" height="500" src="' . admin_url('admin.php?page=GrandMedia&gmediablank=update_plugin') . '"></iframe>';
 
115
  $gmProcessor->page = 'GrandMedia_Update';
116
  } else {
117
  return;
118
  }
119
  }
120
-
121
- $sideLinks = $this->sideLinks();
122
-
123
- if (isset($update_frame)) {
124
- $sideLinks['grandTitle'] = __('Updating GmediaGallery Plugin', 'grand-media');
125
- }
126
  ?>
127
- <div id="gmedia-container">
128
  <div id="gmedia-header" class="clearfix">
129
  <div id="gmedia-logo">Gmedia
130
  <small> by CodEasily.com</small>
@@ -137,12 +133,12 @@ class GmediaAdmin
137
  <?php echo $sideLinks['sideLinks']; ?>
138
 
139
  <?php $installDate = get_option('gmediaInstallDate');
140
- if ($installDate && (strtotime($installDate) < strtotime('2 weeks ago'))) { ?>
141
  <div class="row panel panel-default visible-lg-block">
142
  <div class="panel-heading" data-toggle="collapse" data-target="#support_div_collapse" aria-expanded="true" aria-controls="support_div_collapse" style="cursor:pointer;">
143
  <b><?php _e('Any feedback?', 'grand-media'); ?></b>
144
  </div>
145
- <div class="collapse<?php if (empty($gmGallery->options['license_key'])) {
146
  echo ' in';
147
  } ?>" id="support_div_collapse">
148
  <div class="panel-body">
@@ -159,9 +155,9 @@ class GmediaAdmin
159
  <?php } ?>
160
  <div class="row panel visible-lg-block">
161
  <a class="twitter-timeline" href="https://twitter.com/CodEasily/timelines/648240437141086212" data-widget-id="648245214201692161"></a>
162
- <script>!function (d, s, id) {
163
- var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
164
- if (!d.getElementById(id)) {
165
  js = d.createElement(s);
166
  js.id = id;
167
  js.src = p + "://platform.twitter.com/widgets.js";
@@ -172,20 +168,12 @@ class GmediaAdmin
172
  </div>
173
  <div class="col-sm-10 col-xs-12">
174
  <div id="gm-message"><?php
175
- echo $gmProcessor->alert('success', $gmProcessor->msg);
176
- echo $gmProcessor->alert('danger', $gmProcessor->error);
177
  ?></div>
178
- <?php
179
- if (isset($update_frame)) {
180
- ?>
181
- <div class="panel panel-default">
182
- <div class="panel-body"><?php echo $update_frame; ?></div>
183
- </div>
184
- <?php
185
- } else {
186
- $this->controller();
187
- }
188
- ?>
189
  </div>
190
  </div>
191
  </div>
@@ -193,15 +181,14 @@ class GmediaAdmin
193
  <?php
194
  }
195
 
196
- function sideLinks()
197
- {
198
  global $submenu, $gmProcessor;
199
  $content['sideLinks'] = '
200
  <div id="gmedia-navbar">
201
  <div class="row">
202
  <ul class="list-group">';
203
- foreach ($submenu['GrandMedia'] as $menuKey => $menuItem) {
204
- if ($submenu['GrandMedia'][$menuKey][2] == $gmProcessor->page) {
205
  $iscur = ' active';
206
  $content['grandTitle'] = $submenu['GrandMedia'][$menuKey][3];
207
  } else {
@@ -218,80 +205,81 @@ class GmediaAdmin
218
  return $content;
219
  }
220
 
221
- function controller()
222
- {
223
 
224
  global $gmProcessor;
225
- switch ($gmProcessor->page) {
226
  case 'GrandMedia_AddMedia':
227
- include_once(dirname(__FILE__) . '/addmedia/addmedia.php');
228
- break;
229
  case 'GrandMedia_Terms':
230
- include_once(dirname(__FILE__) . '/terms.php');
231
- if (isset($_GET['edit_album'])) {
232
- gmediaAlbumEdit();
233
- } elseif (isset($_GET['edit_filter'])) {
234
- gmediaFilterEdit();
 
235
  } else {
236
- gmediaTerms();
237
  }
238
- break;
239
  case 'GrandMedia_Galleries':
240
  include_once(dirname(__FILE__) . '/galleries.php');
241
- if (isset($_GET['gallery_module']) || isset($_GET['edit_gallery'])) {
242
  gmediaGalleryEdit();
243
  } else {
244
  gmediaGalleries();
245
  }
246
- break;
247
  case 'GrandMedia_Modules':
248
- include_once(dirname(__FILE__) . '/modules.php');
249
- gmediaModules();
250
- break;
251
  case 'GrandMedia_Settings':
252
- include_once(dirname(__FILE__) . '/settings.php');
253
- gmSettings();
254
- break;
255
  case 'GrandMedia_App':
256
  include_once(dirname(__FILE__) . '/app.php');
257
  gmediaApp();
258
- break;
259
  case 'GrandMedia_WordpressLibrary':
260
  include_once(dirname(__FILE__) . '/wpmedia.php');
261
  grandWPMedia();
262
- break;
 
 
 
 
263
  case 'GrandMedia':
264
  default:
265
- include_once(dirname(__FILE__) . '/library/library.php');
266
- break;
267
  }
268
  }
269
 
270
  /**
271
  * @param $hook
272
  */
273
- function load_scripts($hook)
274
- {
275
  global $gmCore, $gmProcessor, $gmGallery;
276
 
277
  // no need to go on if it's not a plugin page
278
- if ('admin.php' != $hook && strpos($gmCore->_get('page'), 'GrandMedia') === false) {
279
  return;
280
  }
281
 
282
- if ($gmGallery->options['isolation_mode']) {
283
  global $wp_scripts, $wp_styles;
284
- foreach ($wp_scripts->registered as $handle => $wp_script) {
285
- if ((false !== strpos($wp_script->src, '/plugins/')) && (false === strpos($wp_script->src, GMEDIA_FOLDER))) {
286
- if (in_array($handle, $wp_scripts->queue)) {
287
  wp_dequeue_script($handle);
288
  }
289
  wp_deregister_script($handle);
290
  }
291
  }
292
- foreach ($wp_styles->registered as $handle => $wp_style) {
293
- if ((false !== strpos($wp_style->src, '/plugins/')) && (false === strpos($wp_style->src, GMEDIA_FOLDER))) {
294
- if (in_array($handle, $wp_styles->queue)) {
295
  wp_dequeue_style($handle);
296
  }
297
  wp_deregister_style($handle);
@@ -305,11 +293,11 @@ class GmediaAdmin
305
  wp_register_script('selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.min.js', array('jquery'), '0.12.1');
306
  wp_register_style('selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.bootstrap3.css', array('gmedia-bootstrap'), '0.12.1', 'screen');
307
 
308
- if (isset($_GET['page'])) {
309
- switch ($_GET['page']) {
310
  case "GrandMedia" :
311
- if ($gmCore->caps['gmedia_edit_media']) {
312
- if ($gmCore->_get('gmediablank') == 'image_editor') {
313
  wp_enqueue_script('camanjs', $gmCore->gmedia_url . '/assets/image-editor/camanjs/caman.full.min.js', array(), '4.1.2');
314
 
315
  wp_enqueue_style('nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.css', array('gmedia-bootstrap'), '6.1.0');
@@ -319,47 +307,48 @@ class GmediaAdmin
319
  wp_enqueue_script('gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/image-editor.js', array('jquery', 'camanjs'), '0.9.16');
320
  break;
321
  }
322
- if ($gmProcessor->edit_mode) {
323
  wp_enqueue_script('alphanum', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.alphanum.js', array('jquery'), '1.0.16');
324
 
325
  wp_enqueue_script('moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', array('jquery'), '2.5.1');
326
  wp_enqueue_style('datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', array('gmedia-bootstrap'), '2.1.32');
327
  wp_enqueue_script('datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', array(
328
- 'jquery',
329
- 'moment',
330
- 'gmedia-bootstrap'
331
  ), '2.1.32');
332
  }
333
  }
334
  wp_enqueue_style('selectize');
335
  wp_enqueue_script('selectize');
336
- break;
337
  case "GrandMedia_WordpressLibrary" :
338
- if ($gmCore->caps['gmedia_import']) {
339
  wp_enqueue_style('selectize');
340
  wp_enqueue_script('selectize');
341
  }
342
- break;
343
  case "GrandMedia_Terms" :
344
- if ($gmCore->_get('edit_album') && $gmCore->caps['gmedia_album_manage']) {
345
- wp_enqueue_style('jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen');
346
- wp_enqueue_script('jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2');
 
347
 
348
- wp_enqueue_script('tinysort', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.tinysort.js', array('jquery'), '1.5.6');
349
- } elseif (isset($_GET['edit_filter']) && $gmCore->caps['gmedia_filter_manage']) {
350
- wp_enqueue_style('selectize');
351
- wp_enqueue_script('selectize');
 
352
  }
353
-
354
- break;
355
  case "GrandMedia_AddMedia" :
356
- if ($gmCore->caps['gmedia_terms']) {
357
  wp_enqueue_style('selectize');
358
  wp_enqueue_script('selectize');
359
  }
360
- if ($gmCore->caps['gmedia_upload']) {
361
  $tab = $gmCore->_get('tab', 'upload');
362
- if ($tab == 'upload') {
363
  wp_enqueue_style('jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen');
364
  wp_enqueue_script('jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2');
365
 
@@ -367,19 +356,19 @@ class GmediaAdmin
367
 
368
  wp_enqueue_style('jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css', array('jquery-ui-smoothness'), '2.1.2', 'screen');
369
  wp_enqueue_script('jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', array(
370
- 'gmedia-plupload',
371
- 'jquery-ui-full'
372
  ), '2.1.2');
373
 
374
  }
375
  }
376
- break;
377
  case "GrandMedia_Settings" :
378
  case "GrandMedia_App" :
379
  // under construction
380
- break;
381
  case "GrandMedia_Galleries" :
382
- if ($gmCore->caps['gmedia_gallery_manage'] && (isset($_GET['gallery_module']) || isset($_GET['edit_gallery']))) {
383
  wp_enqueue_script('jquery-ui-sortable');
384
  wp_enqueue_style('selectize');
385
  wp_enqueue_script('selectize');
@@ -387,7 +376,7 @@ class GmediaAdmin
387
  wp_enqueue_style('jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', array('gmedia-bootstrap'), '0.9.13');
388
  wp_enqueue_script('jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', array('jquery'), '0.9.13');
389
  }
390
- break;
391
  }
392
  }
393
 
@@ -396,16 +385,15 @@ class GmediaAdmin
396
 
397
  }
398
 
399
- function screen_help()
400
- {
401
  $screen = get_current_screen();
402
  $screen_id = explode('page_', $screen->id, 2);
403
  $screen_id = $screen_id[1];
404
 
405
  $screen->add_help_tab(array(
406
- 'id' => 'help_' . $screen_id . '_support',
407
- 'title' => __('Support'),
408
- 'content' => '<h4>First steps</h4>
409
  <p>If you have any problems with displaying Gmedia Gallery in admin or on website. Before posting to the Forum try next:</p>
410
  <ul>
411
  <li>Exclude plugin conflicts: Disable other plugins one by one and check if it resolve problem</li>
@@ -417,17 +405,17 @@ class GmediaAdmin
417
  | <a href="http://codeasily.com/portfolio/gmedia-gallery-modules/" target="_blank">' . __('Demo', 'grand-media') . '</a>
418
  | <a href="http://codeasily.com/product/one-site-license/" target="_blank">' . __('Premium', 'grand-media') . '</a>
419
  </p>',
420
- ));
421
 
422
- switch ($screen_id) {
423
  case 'GrandMedia' :
424
- break;
425
  case 'GrandMedia_Settings' :
426
- if (current_user_can('manage_options')) {
427
  $screen->add_help_tab(array(
428
- 'id' => 'help_' . $screen_id . '_license',
429
- 'title' => __('License Key'),
430
- 'content' => '<h4>Should I buy it, to use plugin?</h4>
431
  <p>No, plugin is absolutely free and all modules for it are free to install.</p>
432
  <p>Even premium modules are fully functional and free to test, but have backlink labels. To remove baclink labels from premium modules you need license key.</p>
433
  <p>Note: License Key will remove backlinks from all current and future premium modules, so you can use all available modules on one website.</p>
@@ -435,9 +423,9 @@ class GmediaAdmin
435
  <h4>I have license key but I can\'t activate it</h4>
436
  <p>Contact developer <a href="mailto:gmediafolder@gmail.com">gmediafolder@gmail.com</a> with your problem and wait for additional instructions and code for manual activation</p>
437
  <div><a class="btn btn-default" href="' . admin_url('admin.php?page=' . $screen_id . '&license_activate=manual') . '">Manual Activation</a></div>',
438
- ));
439
  }
440
- break;
441
  }
442
  }
443
 
@@ -447,10 +435,9 @@ class GmediaAdmin
447
  *
448
  * @return string
449
  */
450
- function screen_settings($current, $screen)
451
- {
452
  global $gmProcessor, $gmCore;
453
- if (in_array($screen->id, $this->pages)) {
454
 
455
  $gm_screen_options = $gmProcessor->user_options;
456
 
@@ -462,7 +449,7 @@ class GmediaAdmin
462
 
463
  $screen_id = explode('page_', $screen->id, 2);
464
 
465
- switch ($screen_id[1]) {
466
  case 'GrandMedia' :
467
  $settings = '
468
  <div class="form-inline pull-left">
@@ -487,7 +474,7 @@ class GmediaAdmin
487
  </select> <span>' . __('sort order', 'grand-media') . '</span>
488
  </div>
489
  ';
490
- if ($gmCore->_get('edit_mode', false, true)) {
491
  $settings .= '
492
  <div class="form-group">
493
  <select name="gm_screen_options[library_edit_quicktags]" class="form-control input-sm">
@@ -500,11 +487,11 @@ class GmediaAdmin
500
  $settings .= '
501
  </div>
502
  ';
503
- break;
504
  case 'GrandMedia_AddMedia' :
505
  $tab = $gmCore->_get('tab', 'upload');
506
- if ('upload' == $tab) {
507
- $html4_hide = ('html4' == $gm_screen_options['uploader_runtime']) ? ' hide' : '';
508
  $settings = '
509
  <div class="form-inline pull-left">
510
  <div id="uploader_runtime" class="form-group"><span>' . __('Uploader runtime:', 'grand-media') . ' </span>
@@ -530,10 +517,10 @@ class GmediaAdmin
530
  </div>
531
  ';
532
  }
533
- break;
534
  case 'GrandMedia_Terms' :
535
- $taxonomy = $gmCore->_get('term', 'gmedia_album');
536
- if ($gmCore->_get('edit_album')) {
537
  $settings = '
538
  <div class="form-inline pull-left">
539
  <div class="form-group">
@@ -541,7 +528,7 @@ class GmediaAdmin
541
  </div>
542
  </div>
543
  ';
544
- } elseif (! in_array($taxonomy, array('gmedia_category', 'gmedia_filter'))) {
545
  $settings = '
546
  <div class="form-inline pull-left">
547
  <div class="form-group">
@@ -564,9 +551,9 @@ class GmediaAdmin
564
  </div>
565
  ';
566
  }
567
- break;
568
  case 'GrandMedia_Galleries' :
569
- if (! $gmCore->_get('edit_gallery') && ! $gmCore->_get('gallery_module')) {
570
  $settings = '
571
  <div class="form-inline pull-left">
572
  <div class="form-group">
@@ -588,7 +575,7 @@ class GmediaAdmin
588
  </div>
589
  ';
590
  }
591
- break;
592
  case 'GrandMedia_WordpressLibrary' :
593
  $settings = '<p>' . __('Set query options for this page to be loaded by default.', 'grand-media') . '</p>
594
  <div class="form-inline pull-left">
@@ -614,10 +601,10 @@ class GmediaAdmin
614
  </div>
615
  </div>
616
  ';
617
- break;
618
  }
619
 
620
- if ($settings) {
621
  $current = $title . $settings . $wp_screen_options . $button;
622
  }
623
 
@@ -633,10 +620,9 @@ class GmediaAdmin
633
  *
634
  * @return array
635
  */
636
- function screen_settings_save($status, $option, $value)
637
- {
638
  global $user_ID;
639
- if ('gm_screen_options' == $option) {
640
  /*
641
  global $gmGallery;
642
  foreach ( $_POST['gm_screen_options'] as $key => $val ) {
@@ -645,7 +631,7 @@ class GmediaAdmin
645
  update_option( 'gmediaOptions', $gmGallery->options );
646
  */
647
  $gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
648
- if (! is_array($gm_screen_options)) {
649
  $gm_screen_options = array();
650
  }
651
  $value = array_merge($gm_screen_options, $_POST['gm_screen_options']);
4
  * GmediaAdmin - Admin Section for GRAND Media
5
  *
6
  */
7
+ class GmediaAdmin {
 
8
  var $pages = array();
9
 
10
  /**
11
  * constructor
12
  */
13
+ function __construct() {
 
14
  global $pagenow;
15
 
16
+ include_once(GMEDIA_ABSPATH . 'admin/functions.php');
17
+
18
  // Add the admin menu
19
  add_action('admin_menu', array(&$this, 'add_menu'));
20
 
35
  /**
36
  * Load gmedia pages in wpless interface
37
  */
38
+ function gmedia_blank_page() {
 
39
  set_current_screen('GrandMedia_Settings');
40
 
41
  global $gmCore;
45
  $gmediablank = isset($_GET['gmediablank'])? $_GET['gmediablank'] : '';
46
  return "gmedia-blank $gmediablank"; });
47
  */
48
+ add_filter('admin_body_class', create_function('', '$gmediablank = isset($_GET["gmediablank"])? $_GET["gmediablank"] : ""; return "gmedia-blank gmedia_{$gmediablank}";'));
49
  define('IFRAME_REQUEST', true);
50
 
51
  iframe_header('GmediaGallery');
52
 
53
+ switch($gmediablank) {
54
  case 'update_plugin':
55
  require_once(dirname(dirname(__FILE__)) . '/config/update.php');
56
  gmedia_do_update();
57
+ break;
58
  case 'image_editor':
59
  require_once(dirname(dirname(__FILE__)) . '/inc/image-editor.php');
60
  gmedia_image_editor();
61
+ break;
62
  case 'map_editor':
63
  require_once(dirname(dirname(__FILE__)) . '/inc/map-editor.php');
64
  gmedia_map_editor();
65
+ break;
66
+ case 'comments':
67
+ require_once(dirname(__FILE__) . '/tpl/comments.php');
68
+ break;
69
  }
70
 
71
  iframe_footer();
75
  /**
76
  * @return string
77
  */
78
+ function gmedia_blank_page_body_class() {
 
79
  return 'gmedia-blank';
80
  }
81
 
82
  // integrate the menu
83
+ function add_menu() {
 
84
  $gmediaURL = plugins_url(GMEDIA_FOLDER);
85
  $this->pages = array();
86
+ $this->pages[] = add_object_page(__('Gmedia Library', 'grand-media'), 'Gmedia Gallery', 'gmedia_library', 'GrandMedia', array(&$this, 'shell'), $gmediaURL . '/admin/assets/img/gm-icon.png');
87
+ $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Library', 'grand-media'), __('Gmedia Library', 'grand-media'), 'gmedia_library', 'GrandMedia', array(&$this, 'shell'));
88
+ if(current_user_can('gmedia_library')) {
89
+ $this->pages[] = add_submenu_page('GrandMedia', __('Add Media Files', 'grand-media'), __('Add/Import Files', 'grand-media'), 'gmedia_upload', 'GrandMedia_AddMedia', array(&$this, 'shell'));
90
+ $this->pages[] = add_submenu_page('GrandMedia', __('Albums, Tags, Filters...', 'grand-media'), __('Albums, Tags, Filters...', 'grand-media'), 'gmedia_library', 'GrandMedia_Terms', array(&$this, 'shell'));
91
+ $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Galleries', 'grand-media'), __('Create/Manage Galleries...', 'grand-media'), 'gmedia_gallery_manage', 'GrandMedia_Galleries', array(&$this, 'shell'));
92
+ $this->pages[] = add_submenu_page('GrandMedia', __('Modules', 'grand-media'), __('Modules', 'grand-media'), 'gmedia_gallery_manage', 'GrandMedia_Modules', array(&$this, 'shell'));
93
+ $this->pages[] = add_submenu_page('GrandMedia', __('Gmedia Settings', 'grand-media'), __('Settings', 'grand-media'), 'manage_options', 'GrandMedia_Settings', array(&$this, 'shell'));
94
+ $this->pages[] = add_submenu_page('GrandMedia', __('Mobile Application', 'grand-media'), __('Mobile Application', 'grand-media'), 'gmedia_settings', 'GrandMedia_App', array(&$this, 'shell'));
95
+ $this->pages[] = add_submenu_page('GrandMedia', __('Wordpress Media Library', 'grand-media'), __('WP Media Library', 'grand-media'), 'gmedia_import', 'GrandMedia_WordpressLibrary', array(&$this, 'shell'));
96
  }
97
 
98
+ foreach($this->pages as $page) {
99
  add_action("load-$page", array(&$this, 'screen_help'));
100
  }
101
  }
104
  * Load the script for the defined page and load only this code
105
  * Display shell of plugin
106
  */
107
+ function shell() {
108
+ global $gmCore, $gmProcessor, $gmGallery;
109
+
110
+ $sideLinks = $this->sideLinks();
111
 
112
  // check for upgrade
113
+ if(get_option('gmediaDbVersion') != GMEDIA_DBVERSION) {
114
+ if(get_transient('gmediaUpgrade') || (isset($_GET['do_update']) && ('gmedia' == $_GET['do_update']))) {
115
+ $sideLinks['grandTitle'] = __('Updating GmediaGallery Plugin', 'grand-media');
116
+ $sideLinks['sideLinks'] = '';
117
  $gmProcessor->page = 'GrandMedia_Update';
118
  } else {
119
  return;
120
  }
121
  }
 
 
 
 
 
 
122
  ?>
123
+ <div id="gmedia-container" class="gmedia-admin">
124
  <div id="gmedia-header" class="clearfix">
125
  <div id="gmedia-logo">Gmedia
126
  <small> by CodEasily.com</small>
133
  <?php echo $sideLinks['sideLinks']; ?>
134
 
135
  <?php $installDate = get_option('gmediaInstallDate');
136
+ if($installDate && (strtotime($installDate) < strtotime('2 weeks ago'))) { ?>
137
  <div class="row panel panel-default visible-lg-block">
138
  <div class="panel-heading" data-toggle="collapse" data-target="#support_div_collapse" aria-expanded="true" aria-controls="support_div_collapse" style="cursor:pointer;">
139
  <b><?php _e('Any feedback?', 'grand-media'); ?></b>
140
  </div>
141
+ <div class="collapse<?php if(empty($gmGallery->options['license_key'])) {
142
  echo ' in';
143
  } ?>" id="support_div_collapse">
144
  <div class="panel-body">
155
  <?php } ?>
156
  <div class="row panel visible-lg-block">
157
  <a class="twitter-timeline" href="https://twitter.com/CodEasily/timelines/648240437141086212" data-widget-id="648245214201692161"></a>
158
+ <script>!function(d, s, id) {
159
+ var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location)? 'http' : 'https';
160
+ if(!d.getElementById(id)) {
161
  js = d.createElement(s);
162
  js.id = id;
163
  js.src = p + "://platform.twitter.com/widgets.js";
168
  </div>
169
  <div class="col-sm-10 col-xs-12">
170
  <div id="gm-message"><?php
171
+ echo $gmCore->alert('success', $gmProcessor->msg);
172
+ echo $gmCore->alert('danger', $gmProcessor->error);
173
  ?></div>
174
+
175
+ <?php $this->controller(); ?>
176
+
 
 
 
 
 
 
 
 
177
  </div>
178
  </div>
179
  </div>
181
  <?php
182
  }
183
 
184
+ function sideLinks() {
 
185
  global $submenu, $gmProcessor;
186
  $content['sideLinks'] = '
187
  <div id="gmedia-navbar">
188
  <div class="row">
189
  <ul class="list-group">';
190
+ foreach($submenu['GrandMedia'] as $menuKey => $menuItem) {
191
+ if($submenu['GrandMedia'][$menuKey][2] == $gmProcessor->page) {
192
  $iscur = ' active';
193
  $content['grandTitle'] = $submenu['GrandMedia'][$menuKey][3];
194
  } else {
205
  return $content;
206
  }
207
 
208
+ function controller() {
 
209
 
210
  global $gmProcessor;
211
+ switch($gmProcessor->page) {
212
  case 'GrandMedia_AddMedia':
213
+ include_once(dirname(__FILE__) . '/pages/addmedia/addmedia.php');
214
+ break;
215
  case 'GrandMedia_Terms':
216
+ if(isset($_GET['edit_item'])) {
217
+ if('gmedia_album' == $gmProcessor->taxonomy){
218
+ include_once(dirname(__FILE__) . '/pages/taxonomy/edit-album.php');
219
+ } elseif('gmedia_filter' == $gmProcessor->taxonomy) {
220
+ include_once(dirname(__FILE__) . '/pages/taxonomy/edit-filter.php');
221
+ }
222
  } else {
223
+ include_once(dirname(__FILE__) . '/pages/taxonomy/terms.php');
224
  }
225
+ break;
226
  case 'GrandMedia_Galleries':
227
  include_once(dirname(__FILE__) . '/galleries.php');
228
+ if(isset($_GET['gallery_module']) || isset($_GET['edit_gallery'])) {
229
  gmediaGalleryEdit();
230
  } else {
231
  gmediaGalleries();
232
  }
233
+ break;
234
  case 'GrandMedia_Modules':
235
+ include_once(dirname(__FILE__) . '/pages/modules/modules.php');
236
+ break;
 
237
  case 'GrandMedia_Settings':
238
+ include_once(dirname(__FILE__) . '/pages/settings/settings.php');
239
+ break;
 
240
  case 'GrandMedia_App':
241
  include_once(dirname(__FILE__) . '/app.php');
242
  gmediaApp();
243
+ break;
244
  case 'GrandMedia_WordpressLibrary':
245
  include_once(dirname(__FILE__) . '/wpmedia.php');
246
  grandWPMedia();
247
+ break;
248
+ case 'GrandMedia_Update':
249
+ include_once(GMEDIA_ABSPATH . 'config/update.php');
250
+ gmedia_upgrade_progress_panel();
251
+ break;
252
  case 'GrandMedia':
253
  default:
254
+ include_once(dirname(__FILE__) . '/pages/library/library.php');
255
+ break;
256
  }
257
  }
258
 
259
  /**
260
  * @param $hook
261
  */
262
+ function load_scripts($hook) {
 
263
  global $gmCore, $gmProcessor, $gmGallery;
264
 
265
  // no need to go on if it's not a plugin page
266
+ if('admin.php' != $hook && strpos($gmCore->_get('page'), 'GrandMedia') === false) {
267
  return;
268
  }
269
 
270
+ if($gmGallery->options['isolation_mode']) {
271
  global $wp_scripts, $wp_styles;
272
+ foreach($wp_scripts->registered as $handle => $wp_script) {
273
+ if((false !== strpos($wp_script->src, '/plugins/')) && (false === strpos($wp_script->src, GMEDIA_FOLDER))) {
274
+ if(in_array($handle, $wp_scripts->queue)) {
275
  wp_dequeue_script($handle);
276
  }
277
  wp_deregister_script($handle);
278
  }
279
  }
280
+ foreach($wp_styles->registered as $handle => $wp_style) {
281
+ if((false !== strpos($wp_style->src, '/plugins/')) && (false === strpos($wp_style->src, GMEDIA_FOLDER))) {
282
+ if(in_array($handle, $wp_styles->queue)) {
283
  wp_dequeue_style($handle);
284
  }
285
  wp_deregister_style($handle);
293
  wp_register_script('selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.min.js', array('jquery'), '0.12.1');
294
  wp_register_style('selectize', $gmCore->gmedia_url . '/assets/selectize/selectize.bootstrap3.css', array('gmedia-bootstrap'), '0.12.1', 'screen');
295
 
296
+ if(isset($_GET['page'])) {
297
+ switch($_GET['page']) {
298
  case "GrandMedia" :
299
+ if($gmCore->caps['gmedia_edit_media']) {
300
+ if($gmCore->_get('gmediablank') == 'image_editor') {
301
  wp_enqueue_script('camanjs', $gmCore->gmedia_url . '/assets/image-editor/camanjs/caman.full.min.js', array(), '4.1.2');
302
 
303
  wp_enqueue_style('nouislider', $gmCore->gmedia_url . '/assets/image-editor/js/jquery.nouislider.css', array('gmedia-bootstrap'), '6.1.0');
307
  wp_enqueue_script('gmedia-image-editor', $gmCore->gmedia_url . '/assets/image-editor/image-editor.js', array('jquery', 'camanjs'), '0.9.16');
308
  break;
309
  }
310
+ if($gmProcessor->edit_mode) {
311
  wp_enqueue_script('alphanum', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.alphanum.js', array('jquery'), '1.0.16');
312
 
313
  wp_enqueue_script('moment', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/moment.min.js', array('jquery'), '2.5.1');
314
  wp_enqueue_style('datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', array('gmedia-bootstrap'), '2.1.32');
315
  wp_enqueue_script('datetimepicker', $gmCore->gmedia_url . '/assets/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', array(
316
+ 'jquery',
317
+ 'moment',
318
+ 'gmedia-bootstrap'
319
  ), '2.1.32');
320
  }
321
  }
322
  wp_enqueue_style('selectize');
323
  wp_enqueue_script('selectize');
324
+ break;
325
  case "GrandMedia_WordpressLibrary" :
326
+ if($gmCore->caps['gmedia_import']) {
327
  wp_enqueue_style('selectize');
328
  wp_enqueue_script('selectize');
329
  }
330
+ break;
331
  case "GrandMedia_Terms" :
332
+ if(isset($_GET['edit_item'])) {
333
+ if('gmedia_album' == $gmProcessor->taxonomy && $gmCore->caps['gmedia_album_manage']) {
334
+ wp_enqueue_style('jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen');
335
+ wp_enqueue_script('jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2');
336
 
337
+ wp_enqueue_script('tinysort', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.tinysort.js', array('jquery'), '1.5.6');
338
+ } elseif('gmedia_filter' == $gmProcessor->taxonomy && $gmCore->caps['gmedia_filter_manage']) {
339
+ wp_enqueue_style('selectize');
340
+ wp_enqueue_script('selectize');
341
+ }
342
  }
343
+ break;
 
344
  case "GrandMedia_AddMedia" :
345
+ if($gmCore->caps['gmedia_terms']) {
346
  wp_enqueue_style('selectize');
347
  wp_enqueue_script('selectize');
348
  }
349
+ if($gmCore->caps['gmedia_upload']) {
350
  $tab = $gmCore->_get('tab', 'upload');
351
+ if($tab == 'upload') {
352
  wp_enqueue_style('jquery-ui-smoothness', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.min.css', array(), '1.10.2', 'screen');
353
  wp_enqueue_script('jquery-ui-full', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', array(), '1.10.2');
354
 
356
 
357
  wp_enqueue_style('jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css', array('jquery-ui-smoothness'), '2.1.2', 'screen');
358
  wp_enqueue_script('jquery.ui.plupload', $gmCore->gmedia_url . '/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js', array(
359
+ 'gmedia-plupload',
360
+ 'jquery-ui-full'
361
  ), '2.1.2');
362
 
363
  }
364
  }
365
+ break;
366
  case "GrandMedia_Settings" :
367
  case "GrandMedia_App" :
368
  // under construction
369
+ break;
370
  case "GrandMedia_Galleries" :
371
+ if($gmCore->caps['gmedia_gallery_manage'] && (isset($_GET['gallery_module']) || isset($_GET['edit_gallery']))) {
372
  wp_enqueue_script('jquery-ui-sortable');
373
  wp_enqueue_style('selectize');
374
  wp_enqueue_script('selectize');
376
  wp_enqueue_style('jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.css', array('gmedia-bootstrap'), '0.9.13');
377
  wp_enqueue_script('jquery.minicolors', $gmCore->gmedia_url . '/assets/minicolors/jquery.minicolors.js', array('jquery'), '0.9.13');
378
  }
379
+ break;
380
  }
381
  }
382
 
385
 
386
  }
387
 
388
+ function screen_help() {
 
389
  $screen = get_current_screen();
390
  $screen_id = explode('page_', $screen->id, 2);
391
  $screen_id = $screen_id[1];
392
 
393
  $screen->add_help_tab(array(
394
+ 'id' => 'help_' . $screen_id . '_support',
395
+ 'title' => __('Support'),
396
+ 'content' => '<h4>First steps</h4>
397
  <p>If you have any problems with displaying Gmedia Gallery in admin or on website. Before posting to the Forum try next:</p>
398
  <ul>
399
  <li>Exclude plugin conflicts: Disable other plugins one by one and check if it resolve problem</li>
405
  | <a href="http://codeasily.com/portfolio/gmedia-gallery-modules/" target="_blank">' . __('Demo', 'grand-media') . '</a>
406
  | <a href="http://codeasily.com/product/one-site-license/" target="_blank">' . __('Premium', 'grand-media') . '</a>
407
  </p>',
408
+ ));
409
 
410
+ switch($screen_id) {
411
  case 'GrandMedia' :
412
+ break;
413
  case 'GrandMedia_Settings' :
414
+ if(current_user_can('manage_options')) {
415
  $screen->add_help_tab(array(
416
+ 'id' => 'help_' . $screen_id . '_license',
417
+ 'title' => __('License Key'),
418
+ 'content' => '<h4>Should I buy it, to use plugin?</h4>
419
  <p>No, plugin is absolutely free and all modules for it are free to install.</p>
420
  <p>Even premium modules are fully functional and free to test, but have backlink labels. To remove baclink labels from premium modules you need license key.</p>
421
  <p>Note: License Key will remove backlinks from all current and future premium modules, so you can use all available modules on one website.</p>
423
  <h4>I have license key but I can\'t activate it</h4>
424
  <p>Contact developer <a href="mailto:gmediafolder@gmail.com">gmediafolder@gmail.com</a> with your problem and wait for additional instructions and code for manual activation</p>
425
  <div><a class="btn btn-default" href="' . admin_url('admin.php?page=' . $screen_id . '&license_activate=manual') . '">Manual Activation</a></div>',
426
+ ));
427
  }
428
+ break;
429
  }
430
  }
431
 
435
  *
436
  * @return string
437
  */
438
+ function screen_settings($current, $screen) {
 
439
  global $gmProcessor, $gmCore;
440
+ if(in_array($screen->id, $this->pages)) {
441
 
442
  $gm_screen_options = $gmProcessor->user_options;
443
 
449
 
450
  $screen_id = explode('page_', $screen->id, 2);
451
 
452
+ switch($screen_id[1]) {
453
  case 'GrandMedia' :
454
  $settings = '
455
  <div class="form-inline pull-left">
474
  </select> <span>' . __('sort order', 'grand-media') . '</span>
475
  </div>
476
  ';
477
+ if($gmCore->_get('edit_mode', false, true)) {
478
  $settings .= '
479
  <div class="form-group">
480
  <select name="gm_screen_options[library_edit_quicktags]" class="form-control input-sm">
487
  $settings .= '
488
  </div>
489
  ';
490
+ break;
491
  case 'GrandMedia_AddMedia' :
492
  $tab = $gmCore->_get('tab', 'upload');
493
+ if('upload' == $tab) {
494
+ $html4_hide = ('html4' == $gm_screen_options['uploader_runtime'])? ' hide' : '';
495
  $settings = '
496
  <div class="form-inline pull-left">
497
  <div id="uploader_runtime" class="form-group"><span>' . __('Uploader runtime:', 'grand-media') . ' </span>
517
  </div>
518
  ';
519
  }
520
+ break;
521
  case 'GrandMedia_Terms' :
522
+ $taxonomy = $gmCore->_get('taxonomy', 'gmedia_album');
523
+ if('gmedia_album' == $taxonomy && isset($_GET['edit_item'])) {
524
  $settings = '
525
  <div class="form-inline pull-left">
526
  <div class="form-group">
528
  </div>
529
  </div>
530
  ';
531
+ } elseif(!in_array($taxonomy, array('gmedia_category', 'gmedia_filter'))) {
532
  $settings = '
533
  <div class="form-inline pull-left">
534
  <div class="form-group">
551
  </div>
552
  ';
553
  }
554
+ break;
555
  case 'GrandMedia_Galleries' :
556
+ if(!$gmCore->_get('edit_gallery') && !$gmCore->_get('gallery_module')) {
557
  $settings = '
558
  <div class="form-inline pull-left">
559
  <div class="form-group">
575
  </div>
576
  ';
577
  }
578
+ break;
579
  case 'GrandMedia_WordpressLibrary' :
580
  $settings = '<p>' . __('Set query options for this page to be loaded by default.', 'grand-media') . '</p>
581
  <div class="form-inline pull-left">
601
  </div>
602
  </div>
603
  ';
604
+ break;
605
  }
606
 
607
+ if($settings) {
608
  $current = $title . $settings . $wp_screen_options . $button;
609
  }
610
 
620
  *
621
  * @return array
622
  */
623
+ function screen_settings_save($status, $option, $value) {
 
624
  global $user_ID;
625
+ if('gm_screen_options' == $option) {
626
  /*
627
  global $gmGallery;
628
  foreach ( $_POST['gm_screen_options'] as $key => $val ) {
631
  update_option( 'gmediaOptions', $gmGallery->options );
632
  */
633
  $gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
634
+ if(!is_array($gm_screen_options)) {
635
  $gm_screen_options = array();
636
  }
637
  $value = array_merge($gm_screen_options, $_POST['gm_screen_options']);
admin/ajax.php CHANGED
@@ -133,7 +133,7 @@ function gmedia_update_data() {
133
 
134
  add_action('wp_ajax_gmedit_save', 'gmedit_save');
135
  function gmedit_save() {
136
- global $gmDB, $gmCore, $gmGallery, $gmProcessor;
137
  check_ajax_referer("gmedit-save");
138
  if(!current_user_can('gmedia_edit_media')) {
139
  die('-1');
@@ -227,7 +227,7 @@ function gmedit_save() {
227
  }
228
  // Thumbnail
229
  if('web_thumb' == $applyto) {
230
- $size_ratio = $size[0]/$size[1];
231
  $thumbimg['resize'] = (((1 >= $size_ratio) && ($thumbimg['width'] > $size[0])) || ((1 <= $size_ratio) && ($thumbimg['height'] > $size[1])))? false : true;
232
  if($thumbimg['resize']) {
233
  $editor = wp_get_image_editor($editfile);
@@ -237,8 +237,8 @@ function gmedit_save() {
237
  }
238
 
239
  $editor->set_quality($thumbimg['quality']);
240
- $ed_size = $editor->get_size();
241
- $ed_ratio = $ed_size['width']/$ed_size['height'];
242
  if(1 > $ed_ratio) {
243
  $resized = $editor->resize($thumbimg['width'], 0, $thumbimg['crop']);
244
  } else {
@@ -282,9 +282,9 @@ function gmedit_save() {
282
  } while(0);
283
 
284
  if(empty($fail)) {
285
- $out = array('msg' => $gmProcessor->alert('info', $success), 'modified' => $gmedia['modified']);
286
  } else {
287
- $out = array('error' => $gmProcessor->alert('danger', $fail));
288
  }
289
 
290
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
@@ -296,7 +296,7 @@ function gmedit_save() {
296
 
297
  add_action('wp_ajax_gmedit_restore', 'gmedit_restore');
298
  function gmedit_restore() {
299
- global $gmDB, $gmCore, $gmGallery, $gmProcessor;
300
  check_ajax_referer("gmedit-save");
301
  if(!current_user_can('gmedia_edit_media')) {
302
  die('-1');
@@ -366,7 +366,7 @@ function gmedit_restore() {
366
  }
367
  }
368
 
369
- $size_ratio = $size[0]/$size[1];
370
 
371
  $angle = 0;
372
  $image_meta = @$gmCore->wp_read_image_metadata($fileinfo['filepath_original']);
@@ -376,17 +376,17 @@ function gmedit_restore() {
376
  $angle = 180;
377
  break;
378
  case 6:
379
- $angle = -90;
380
- $size_ratio = $size[1]/$size[0];
381
  break;
382
  case 8:
383
- $angle = 90;
384
- $size_ratio = $size[1]/$size[0];
385
  break;
386
  }
387
  }
388
 
389
- $webimg['resize'] = (($webimg['width'] < $size[0]) || ($webimg['height'] < $size[1]))? true : false;
390
  $thumbimg['resize'] = (((1 >= $size_ratio) && ($thumbimg['width'] > $size[0])) || ((1 <= $size_ratio) && ($thumbimg['height'] > $size[1])))? false : true;
391
 
392
  if($webimg['resize'] || $thumbimg['resize'] || $angle) {
@@ -428,8 +428,8 @@ function gmedit_restore() {
428
  // Thumbnail
429
  $editor->set_quality($thumbimg['quality']);
430
  if($thumbimg['resize']) {
431
- $ed_size = $editor->get_size();
432
- $ed_ratio = $ed_size['width']/$ed_size['height'];
433
  if(1 > $ed_ratio) {
434
  $resized = $editor->resize($thumbimg['width'], 0, $thumbimg['crop']);
435
  } else {
@@ -466,9 +466,9 @@ function gmedit_restore() {
466
  } while(0);
467
 
468
  if(empty($fail)) {
469
- $out = array('msg' => $gmProcessor->alert('info', $success), 'modified' => $gmedia['modified']);
470
  } else {
471
- $out = array('error' => $gmProcessor->alert('danger', $fail));
472
  }
473
 
474
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
@@ -491,9 +491,18 @@ function gmedia_get_modal() {
491
  if(!current_user_can('gmedia_gallery_manage')) {
492
  die('-1');
493
  }
 
494
  $modal_title = __('Quick Gallery from selected items', 'grand-media');
495
  $modal_button = __('Create Quick Gallery', 'grand-media');
496
  break;
 
 
 
 
 
 
 
 
497
  case 'exclude_categories':
498
  case 'filter_categories':
499
  $modal_title = __('Show Images from Categories', 'grand-media');
@@ -582,9 +591,10 @@ function gmedia_get_modal() {
582
  <?php
583
  switch($modal) {
584
  case 'quick_gallery':
585
- global $user_ID;
586
- $ckey = "gmuser_{$user_ID}_library";
587
- $selected = isset($_COOKIE[$ckey])? $_COOKIE[$ckey] : '';
 
588
  if(empty($selected)) {
589
  _e('No selected Gmedia. Select at least one item in library.', 'grand-media');
590
  break;
@@ -654,21 +664,22 @@ function gmedia_get_modal() {
654
  break;
655
  case 'exclude_categories':
656
  case 'filter_categories':
657
- $gm_terms = $gmDB->get_terms('gmedia_category');
658
- ?>
659
- <div class="checkbox"><label><input type="checkbox" name="cat[]" value="0"> <?php _e('Uncategorized', 'grand-media'); ?></label></div>
660
- <?php if(count($gm_terms)) {
661
- foreach($gm_terms as $term) {
662
- if($term->count) {
663
  ?>
664
- <div class="checkbox">
665
- <label><input type="checkbox" name="cat[]" value="<?php echo $term->term_id; ?>"> <?php echo esc_html($term->name); ?></label>
666
- <span class="badge pull-right"><?php echo $term->count; ?></span>
667
- </div>
668
- <?php
669
- }
670
- }
671
- }
 
 
 
 
 
 
672
  break;
673
  case 'assign_category':
674
  $term_type = 'gmedia_category';
@@ -705,7 +716,7 @@ function gmedia_get_modal() {
705
  } else {
706
  $author_name .= '(' . __('shared', 'grand-media') . ')';
707
  }
708
- if('public' != $term->status) {
709
  $author_name .= ' [' . $term->status . ']';
710
  }
711
  if($author_name) {
@@ -744,7 +755,7 @@ function gmedia_get_modal() {
744
  } else {
745
  $author_name .= ' &nbsp; (' . __('shared', 'grand-media') . ')';
746
  }
747
- if('public' != $term->status) {
748
  $author_name .= ' [' . $term->status . ']';
749
  }
750
  $terms_album .= '<option value="' . $term->term_id . '" data-count="' . $term->count . '" data-name="' . esc_html($term->name) . '" data-meta="' . $author_name . '">' . esc_html($term->name) . $author_name . '</option>' . "\n";
@@ -855,7 +866,6 @@ function gmedia_get_modal() {
855
  case 'add_tags':
856
  $gm_terms = $gmDB->get_terms('gmedia_tag', array('fields' => 'names_count'));
857
  $gm_terms = array_values($gm_terms);
858
- if(count($gm_terms)){
859
  ?>
860
  <div class="form-group">
861
  <input id="combobox_gmedia_tag" name="tag_names" class="form-control input-sm" value="" placeholder="<?php _e('Add Tags...', 'grand-media'); ?>"/>
@@ -904,11 +914,6 @@ function gmedia_get_modal() {
904
  });
905
  </script>
906
  <?php
907
- } else {
908
- $modal_button = false; ?>
909
- <p class="notags"><?php _e('No tags', 'grand-media'); ?></p>
910
- <?php
911
- }
912
  break;
913
  case 'delete_tags':
914
  // get selected items in Gmedia Library
@@ -997,7 +1002,7 @@ function gmedia_get_modal() {
997
  _e('There is no Filters created yet.');
998
  if($gmCore->caps['gmedia_filter_manage']) {
999
  ?>
1000
- <a href="<?php echo add_query_arg(array('page' => 'GrandMedia_Terms', 'edit_filter' => '0'), admin_url('admin.php')); ?>"><?php _e('Create Filter', 'grand-media'); ?></a>
1001
  <?php } ?>
1002
  </p>
1003
  <?php }
@@ -1091,11 +1096,19 @@ function gmedia_get_modal() {
1091
  <label><?php _e('Status', 'grand-media'); ?></label>
1092
  <select class="form-control input-sm batch_set" name="batch_status">
1093
  <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
1094
- <option value="public"><?php _e('Public', 'grand-media'); ?></option>
1095
  <option value="private"><?php _e('Private', 'grand-media'); ?></option>
1096
  <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
1097
  </select>
1098
  </div>
 
 
 
 
 
 
 
 
1099
  <?php $user_ids = current_user_can('gmedia_delete_others_media')? $gmCore->get_editable_user_ids() : false;
1100
  if($user_ids){
1101
  if(!in_array($user_ID, $user_ids)) {
@@ -1151,11 +1164,11 @@ function gmedia_get_modal() {
1151
 
1152
  add_action('wp_ajax_gmedia_tag_edit', 'gmedia_tag_edit');
1153
  function gmedia_tag_edit() {
1154
- global $gmCore, $gmDB, $gmProcessor;
1155
 
1156
  check_ajax_referer('GmediaTerms');
1157
  if(!current_user_can('gmedia_tag_manage') && !current_user_can('gmedia_edit_others_media')) {
1158
- $out['error'] = $gmProcessor->alert('danger', __("You are not allowed to edit others media", 'grand-media'));
1159
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1160
  echo json_encode($out);
1161
  die();
@@ -1169,18 +1182,18 @@ function gmedia_tag_edit() {
1169
  if(!$gmDB->term_exists($term['name'], $term['taxonomy'])) {
1170
  $term_id = $gmDB->update_term($term['term_id'], $term['taxonomy'], $term);
1171
  if(is_wp_error($term_id)) {
1172
- $out['error'] = $gmProcessor->alert('danger', $term_id->get_error_message());
1173
  } else {
1174
- $out['msg'] = $gmProcessor->alert('info', sprintf(__("Tag #%d successfuly updated", 'grand-media'), $term_id));
1175
  }
1176
  } else {
1177
- $out['error'] = $gmProcessor->alert('danger', __("A term with the name provided already exists", 'grand-media'));
1178
  }
1179
  } else {
1180
- $out['error'] = $gmProcessor->alert('danger', __("A term with the id provided do not exists", 'grand-media'));
1181
  }
1182
  } else {
1183
- $out['error'] = $gmProcessor->alert('danger', __("Term name can't be only digits or empty", 'grand-media'));
1184
  }
1185
 
1186
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
@@ -1192,12 +1205,12 @@ function gmedia_tag_edit() {
1192
 
1193
  add_action('wp_ajax_gmedia_module_preset_delete', 'gmedia_module_preset_delete');
1194
  function gmedia_module_preset_delete() {
1195
- global $gmCore, $gmDB, $gmProcessor;
1196
  $out = array('error' => '');
1197
 
1198
  check_ajax_referer('GmediaGallery');
1199
  if(!current_user_can('gmedia_gallery_manage')) {
1200
- $out['error'] = $gmProcessor->alert('danger', __("You are not allowed to manage galleries", 'grand-media'));
1201
  } else {
1202
  $taxonomy = 'gmedia_module';
1203
  $term_id = intval($gmCore->_post('preset_id', 0));
@@ -1216,11 +1229,11 @@ function gmedia_module_preset_delete() {
1216
 
1217
  add_action('wp_ajax_gmedia_module_install', 'gmedia_module_install');
1218
  function gmedia_module_install() {
1219
- global $gmCore, $gmProcessor, $gmGallery;
1220
 
1221
  check_ajax_referer('GmediaModule');
1222
  if(!current_user_can('gmedia_module_manage')) {
1223
- echo $gmProcessor->alert('danger', __('You are not allowed to install modules'));
1224
  die();
1225
  }
1226
 
@@ -1228,20 +1241,20 @@ function gmedia_module_install() {
1228
  $module = $gmCore->_post('module');
1229
  $mzip = download_url($download);
1230
  if(is_wp_error($mzip)) {
1231
- echo $gmProcessor->alert('danger', $mzip->get_error_message());
1232
  die();
1233
  }
1234
 
1235
  $mzip = str_replace("\\", "/", $mzip);
1236
  $to_folder = $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/';
1237
  if(!wp_mkdir_p($to_folder)) {
1238
- echo $gmProcessor->alert('danger', sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?', 'grand-media'), $to_folder));
1239
  die();
1240
  }
1241
  if(!is_writable($to_folder)) {
1242
  @chmod($to_folder, 0755);
1243
  if(!is_writable($to_folder)) {
1244
- echo $gmProcessor->alert('danger', sprintf(__('Directory %s is not writable by the server.', 'grand-media'), $to_folder));
1245
  die();
1246
  }
1247
  }
@@ -1257,6 +1270,9 @@ function gmedia_module_install() {
1257
  } elseif($wp_filesystem->errors->get_error_code()) {
1258
  $result = new WP_Error('fs_error', __('Filesystem error', 'flag'), $wp_filesystem->errors);
1259
  } else {
 
 
 
1260
  $result = unzip_file($mzip, $to_folder);
1261
  }
1262
 
@@ -1264,13 +1280,13 @@ function gmedia_module_install() {
1264
  unlink($mzip);
1265
 
1266
  if(is_wp_error($result)) {
1267
- echo $gmProcessor->alert('danger', $result->get_error_message());
1268
  die();
1269
  } else {
1270
- echo $gmProcessor->alert('success', sprintf(__("The `%s` module successfuly installed", 'flag'), $module));
1271
  }
1272
  } else {
1273
- echo $gmProcessor->alert('danger', __('No file specified', 'grand-media'));
1274
  }
1275
 
1276
  die();
@@ -1333,7 +1349,7 @@ function gmedia_import_wpmedia_modal() {
1333
  $terms_album = '';
1334
  if(count($gm_terms)) {
1335
  foreach($gm_terms as $term) {
1336
- $terms_album .= '<option value="' . esc_attr($term->term_id) . '">' . esc_html($term->name) . ($term->global? '' : __(' (shared)', 'grand-media')) . ('public' == $term->status? '' : " [{$term->status}]") . '</option>' . "\n";
1337
  }
1338
  }
1339
  ?>
@@ -1926,7 +1942,7 @@ function gmedia_import_handler() {
1926
 
1927
  add_action('wp_ajax_gmedia_application', 'gmedia_application');
1928
  function gmedia_application() {
1929
- global $gmCore;
1930
 
1931
  // if nonce is not correct it returns -1
1932
  check_ajax_referer('GmediaService');
@@ -1941,7 +1957,16 @@ function gmedia_application() {
1941
  $_data = $gmCore->_post('data');
1942
  wp_parse_str($_data, $data);
1943
 
1944
- $result = $gmCore->app_service($service, $data);
 
 
 
 
 
 
 
 
 
1945
 
1946
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1947
  echo json_encode($result);
@@ -1951,7 +1976,7 @@ function gmedia_application() {
1951
 
1952
  add_action('wp_ajax_gmedia_share_page', 'gmedia_share_page');
1953
  function gmedia_share_page() {
1954
- global $gmCore, $gmProcessor, $user_ID;
1955
  // if nonce is not correct it returns -1
1956
  check_ajax_referer('share_modal', '_sharenonce');
1957
 
@@ -1959,7 +1984,7 @@ function gmedia_share_page() {
1959
  $email = $gmCore->_post('email', '');
1960
  $sharemessage = $gmCore->_post('message', '');
1961
  if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
1962
- echo $gmProcessor->alert('danger', __('Invalid email', 'grand-media') . ': ' . esc_html($email));
1963
  die();
1964
  }
1965
 
@@ -2012,7 +2037,7 @@ EOT;
2012
 
2013
  $headers = array('Content-Type: text/html; charset=UTF-8');
2014
  if(wp_mail($email, $subject, $message, $headers)) {
2015
- echo $gmProcessor->alert('success', sprintf(__('Message sent to %s', 'grand-media'), $email));
2016
  }
2017
 
2018
  die();
@@ -2198,6 +2223,37 @@ function gmedia_term_delete_custom_field() {
2198
 
2199
  }
2200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2201
  add_action('wp_ajax_gmedia_module_interaction', 'gmedia_module_interaction');
2202
  add_action('wp_ajax_nopriv_gmedia_module_interaction', 'gmedia_module_interaction');
2203
  function gmedia_module_interaction() {
@@ -2274,3 +2330,48 @@ function gmedia_module_interaction() {
2274
  die();
2275
  }
2276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
  add_action('wp_ajax_gmedit_save', 'gmedit_save');
135
  function gmedit_save() {
136
+ global $gmDB, $gmCore, $gmGallery;
137
  check_ajax_referer("gmedit-save");
138
  if(!current_user_can('gmedia_edit_media')) {
139
  die('-1');
227
  }
228
  // Thumbnail
229
  if('web_thumb' == $applyto) {
230
+ $size_ratio = $size[0] / $size[1];
231
  $thumbimg['resize'] = (((1 >= $size_ratio) && ($thumbimg['width'] > $size[0])) || ((1 <= $size_ratio) && ($thumbimg['height'] > $size[1])))? false : true;
232
  if($thumbimg['resize']) {
233
  $editor = wp_get_image_editor($editfile);
237
  }
238
 
239
  $editor->set_quality($thumbimg['quality']);
240
+ $ed_size = $editor->get_size();
241
+ $ed_ratio = $ed_size['width'] / $ed_size['height'];
242
  if(1 > $ed_ratio) {
243
  $resized = $editor->resize($thumbimg['width'], 0, $thumbimg['crop']);
244
  } else {
282
  } while(0);
283
 
284
  if(empty($fail)) {
285
+ $out = array('msg' => $gmCore->alert('info', $success), 'modified' => $gmedia['modified']);
286
  } else {
287
+ $out = array('error' => $gmCore->alert('danger', $fail));
288
  }
289
 
290
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
296
 
297
  add_action('wp_ajax_gmedit_restore', 'gmedit_restore');
298
  function gmedit_restore() {
299
+ global $gmDB, $gmCore, $gmGallery;
300
  check_ajax_referer("gmedit-save");
301
  if(!current_user_can('gmedia_edit_media')) {
302
  die('-1');
366
  }
367
  }
368
 
369
+ $size_ratio = $size[0] / $size[1];
370
 
371
  $angle = 0;
372
  $image_meta = @$gmCore->wp_read_image_metadata($fileinfo['filepath_original']);
376
  $angle = 180;
377
  break;
378
  case 6:
379
+ $angle = 270;
380
+ $size_ratio = $size[1] / $size[0];
381
  break;
382
  case 8:
383
+ $angle = 90;
384
+ $size_ratio = $size[1] / $size[0];
385
  break;
386
  }
387
  }
388
 
389
+ $webimg['resize'] = (($webimg['width'] < $size[0]) || ($webimg['height'] < $size[1]))? true : false;
390
  $thumbimg['resize'] = (((1 >= $size_ratio) && ($thumbimg['width'] > $size[0])) || ((1 <= $size_ratio) && ($thumbimg['height'] > $size[1])))? false : true;
391
 
392
  if($webimg['resize'] || $thumbimg['resize'] || $angle) {
428
  // Thumbnail
429
  $editor->set_quality($thumbimg['quality']);
430
  if($thumbimg['resize']) {
431
+ $ed_size = $editor->get_size();
432
+ $ed_ratio = $ed_size['width'] / $ed_size['height'];
433
  if(1 > $ed_ratio) {
434
  $resized = $editor->resize($thumbimg['width'], 0, $thumbimg['crop']);
435
  } else {
466
  } while(0);
467
 
468
  if(empty($fail)) {
469
+ $out = array('msg' => $gmCore->alert('info', $success), 'modified' => $gmedia['modified']);
470
  } else {
471
+ $out = array('error' => $gmCore->alert('danger', $fail));
472
  }
473
 
474
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
491
  if(!current_user_can('gmedia_gallery_manage')) {
492
  die('-1');
493
  }
494
+ $ckey = "gmuser_{$user_ID}_library";
495
  $modal_title = __('Quick Gallery from selected items', 'grand-media');
496
  $modal_button = __('Create Quick Gallery', 'grand-media');
497
  break;
498
+ case 'quick_gallery_stack':
499
+ if(!current_user_can('gmedia_gallery_manage')) {
500
+ die('-1');
501
+ }
502
+ $ckey = "gmuser_{$user_ID}_library_stack";
503
+ $modal_title = __('Quick Gallery from Stack', 'grand-media');
504
+ $modal_button = __('Create Quick Gallery', 'grand-media');
505
+ break;
506
  case 'exclude_categories':
507
  case 'filter_categories':
508
  $modal_title = __('Show Images from Categories', 'grand-media');
591
  <?php
592
  switch($modal) {
593
  case 'quick_gallery':
594
+ case 'quick_gallery_stack':
595
+ if(!empty($ckey)) {
596
+ $selected = isset($_COOKIE[$ckey])? $_COOKIE[$ckey] : '';
597
+ }
598
  if(empty($selected)) {
599
  _e('No selected Gmedia. Select at least one item in library.', 'grand-media');
600
  break;
664
  break;
665
  case 'exclude_categories':
666
  case 'filter_categories':
667
+ $gm_terms = $gmDB->get_terms('gmedia_category');
 
 
 
 
 
668
  ?>
669
+ <div class="checkbox"><label><input type="checkbox" name="cat[]" value="0"> <?php _e('Uncategorized', 'grand-media'); ?></label></div>
670
+ <?php
671
+ if(count($gm_terms)) {
672
+ foreach($gm_terms as $term) {
673
+ if($term->count) {
674
+ ?>
675
+ <div class="checkbox">
676
+ <label><input type="checkbox" name="cat[]" value="<?php echo $term->term_id; ?>"> <?php echo esc_html($term->name); ?></label>
677
+ <span class="badge pull-right"><?php echo $term->count; ?></span>
678
+ </div>
679
+ <?php
680
+ }
681
+ }
682
+ }
683
  break;
684
  case 'assign_category':
685
  $term_type = 'gmedia_category';
716
  } else {
717
  $author_name .= '(' . __('shared', 'grand-media') . ')';
718
  }
719
+ if('publish' != $term->status) {
720
  $author_name .= ' [' . $term->status . ']';
721
  }
722
  if($author_name) {
755
  } else {
756
  $author_name .= ' &nbsp; (' . __('shared', 'grand-media') . ')';
757
  }
758
+ if('publish' != $term->status) {
759
  $author_name .= ' [' . $term->status . ']';
760
  }
761
  $terms_album .= '<option value="' . $term->term_id . '" data-count="' . $term->count . '" data-name="' . esc_html($term->name) . '" data-meta="' . $author_name . '">' . esc_html($term->name) . $author_name . '</option>' . "\n";
866
  case 'add_tags':
867
  $gm_terms = $gmDB->get_terms('gmedia_tag', array('fields' => 'names_count'));
868
  $gm_terms = array_values($gm_terms);
 
869
  ?>
870
  <div class="form-group">
871
  <input id="combobox_gmedia_tag" name="tag_names" class="form-control input-sm" value="" placeholder="<?php _e('Add Tags...', 'grand-media'); ?>"/>
914
  });
915
  </script>
916
  <?php
 
 
 
 
 
917
  break;
918
  case 'delete_tags':
919
  // get selected items in Gmedia Library
1002
  _e('There is no Filters created yet.');
1003
  if($gmCore->caps['gmedia_filter_manage']) {
1004
  ?>
1005
+ <a href="<?php echo add_query_arg(array('page' => 'GrandMedia_Terms', 'taxonomy' => 'gmedia_filter', 'edit_item' => '0'), admin_url('admin.php')); ?>"><?php _e('Create Filter', 'grand-media'); ?></a>
1006
  <?php } ?>
1007
  </p>
1008
  <?php }
1096
  <label><?php _e('Status', 'grand-media'); ?></label>
1097
  <select class="form-control input-sm batch_set" name="batch_status">
1098
  <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
1099
+ <option value="publish"><?php _e('Public', 'grand-media'); ?></option>
1100
  <option value="private"><?php _e('Private', 'grand-media'); ?></option>
1101
  <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
1102
  </select>
1103
  </div>
1104
+ <div class="form-group">
1105
+ <label><?php _e('Comment Status', 'grand-media'); ?></label>
1106
+ <select class="form-control input-sm batch_set" name="batch_comment_status">
1107
+ <option value=""><?php _e('Skip. Do not change', 'grand-media'); ?></option>
1108
+ <option value="open"><?php _e('Open', 'grand-media'); ?></option>
1109
+ <option value="closed"><?php _e('Closed', 'grand-media'); ?></option>
1110
+ </select>
1111
+ </div>
1112
  <?php $user_ids = current_user_can('gmedia_delete_others_media')? $gmCore->get_editable_user_ids() : false;
1113
  if($user_ids){
1114
  if(!in_array($user_ID, $user_ids)) {
1164
 
1165
  add_action('wp_ajax_gmedia_tag_edit', 'gmedia_tag_edit');
1166
  function gmedia_tag_edit() {
1167
+ global $gmCore, $gmDB;
1168
 
1169
  check_ajax_referer('GmediaTerms');
1170
  if(!current_user_can('gmedia_tag_manage') && !current_user_can('gmedia_edit_others_media')) {
1171
+ $out['error'] = $gmCore->alert('danger', __("You are not allowed to edit others media", 'grand-media'));
1172
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1173
  echo json_encode($out);
1174
  die();
1182
  if(!$gmDB->term_exists($term['name'], $term['taxonomy'])) {
1183
  $term_id = $gmDB->update_term($term['term_id'], $term['taxonomy'], $term);
1184
  if(is_wp_error($term_id)) {
1185
+ $out['error'] = $gmCore->alert('danger', $term_id->get_error_message());
1186
  } else {
1187
+ $out['msg'] = $gmCore->alert('info', sprintf(__("Tag #%d successfuly updated", 'grand-media'), $term_id));
1188
  }
1189
  } else {
1190
+ $out['error'] = $gmCore->alert('danger', __("A term with the name provided already exists", 'grand-media'));
1191
  }
1192
  } else {
1193
+ $out['error'] = $gmCore->alert('danger', __("A term with the id provided do not exists", 'grand-media'));
1194
  }
1195
  } else {
1196
+ $out['error'] = $gmCore->alert('danger', __("Term name can't be only digits or empty", 'grand-media'));
1197
  }
1198
 
1199
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1205
 
1206
  add_action('wp_ajax_gmedia_module_preset_delete', 'gmedia_module_preset_delete');
1207
  function gmedia_module_preset_delete() {
1208
+ global $gmCore, $gmDB;
1209
  $out = array('error' => '');
1210
 
1211
  check_ajax_referer('GmediaGallery');
1212
  if(!current_user_can('gmedia_gallery_manage')) {
1213
+ $out['error'] = $gmCore->alert('danger', __("You are not allowed to manage galleries", 'grand-media'));
1214
  } else {
1215
  $taxonomy = 'gmedia_module';
1216
  $term_id = intval($gmCore->_post('preset_id', 0));
1229
 
1230
  add_action('wp_ajax_gmedia_module_install', 'gmedia_module_install');
1231
  function gmedia_module_install() {
1232
+ global $gmCore, $gmGallery;
1233
 
1234
  check_ajax_referer('GmediaModule');
1235
  if(!current_user_can('gmedia_module_manage')) {
1236
+ echo $gmCore->alert('danger', __('You are not allowed to install modules'));
1237
  die();
1238
  }
1239
 
1241
  $module = $gmCore->_post('module');
1242
  $mzip = download_url($download);
1243
  if(is_wp_error($mzip)) {
1244
+ echo $gmCore->alert('danger', $mzip->get_error_message());
1245
  die();
1246
  }
1247
 
1248
  $mzip = str_replace("\\", "/", $mzip);
1249
  $to_folder = $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/';
1250
  if(!wp_mkdir_p($to_folder)) {
1251
+ echo $gmCore->alert('danger', sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?', 'grand-media'), $to_folder));
1252
  die();
1253
  }
1254
  if(!is_writable($to_folder)) {
1255
  @chmod($to_folder, 0755);
1256
  if(!is_writable($to_folder)) {
1257
+ echo $gmCore->alert('danger', sprintf(__('Directory %s is not writable by the server.', 'grand-media'), $to_folder));
1258
  die();
1259
  }
1260
  }
1270
  } elseif($wp_filesystem->errors->get_error_code()) {
1271
  $result = new WP_Error('fs_error', __('Filesystem error', 'flag'), $wp_filesystem->errors);
1272
  } else {
1273
+ if($module && is_dir($to_folder . $module)){
1274
+ $gmCore->delete_folder($to_folder . $module);
1275
+ }
1276
  $result = unzip_file($mzip, $to_folder);
1277
  }
1278
 
1280
  unlink($mzip);
1281
 
1282
  if(is_wp_error($result)) {
1283
+ echo $gmCore->alert('danger', $result->get_error_message());
1284
  die();
1285
  } else {
1286
+ echo $gmCore->alert('success', sprintf(__("The `%s` module successfuly installed", 'flag'), $module));
1287
  }
1288
  } else {
1289
+ echo $gmCore->alert('danger', __('No file specified', 'grand-media'));
1290
  }
1291
 
1292
  die();
1349
  $terms_album = '';
1350
  if(count($gm_terms)) {
1351
  foreach($gm_terms as $term) {
1352
+ $terms_album .= '<option value="' . esc_attr($term->term_id) . '">' . esc_html($term->name) . ($term->global? '' : __(' (shared)', 'grand-media')) . ('publish' == $term->status? '' : " [{$term->status}]") . '</option>' . "\n";
1353
  }
1354
  }
1355
  ?>
1942
 
1943
  add_action('wp_ajax_gmedia_application', 'gmedia_application');
1944
  function gmedia_application() {
1945
+ global $gmCore, $gmGallery;
1946
 
1947
  // if nonce is not correct it returns -1
1948
  check_ajax_referer('GmediaService');
1957
  $_data = $gmCore->_post('data');
1958
  wp_parse_str($_data, $data);
1959
 
1960
+ $options = $gmGallery->options;
1961
+ $options['site_email'] = $data['site_email'];
1962
+ $options['site_title'] = $data['site_title'];
1963
+ $options['site_description'] = $data['site_description'];
1964
+ if($options != $gmGallery->options) {
1965
+ $gmGallery->options = $options;
1966
+ update_option('gmediaOptions', $options);
1967
+ }
1968
+
1969
+ $result = $gmCore->app_service($service);
1970
 
1971
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1972
  echo json_encode($result);
1976
 
1977
  add_action('wp_ajax_gmedia_share_page', 'gmedia_share_page');
1978
  function gmedia_share_page() {
1979
+ global $gmCore, $user_ID;
1980
  // if nonce is not correct it returns -1
1981
  check_ajax_referer('share_modal', '_sharenonce');
1982
 
1984
  $email = $gmCore->_post('email', '');
1985
  $sharemessage = $gmCore->_post('message', '');
1986
  if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
1987
+ echo $gmCore->alert('danger', __('Invalid email', 'grand-media') . ': ' . esc_html($email));
1988
  die();
1989
  }
1990
 
2037
 
2038
  $headers = array('Content-Type: text/html; charset=UTF-8');
2039
  if(wp_mail($email, $subject, $message, $headers)) {
2040
+ echo $gmCore->alert('success', sprintf(__('Message sent to %s', 'grand-media'), $email));
2041
  }
2042
 
2043
  die();
2223
 
2224
  }
2225
 
2226
+ add_action('wp_ajax_gmedia_upgrade_process', 'gmedia_upgrade_process');
2227
+ function gmedia_upgrade_process() {
2228
+
2229
+ $db_version = get_option('gmediaDbVersion');
2230
+ $info = get_transient('gmediaHeavyJob');
2231
+ $result = array( 'content' => '' );
2232
+
2233
+ $upgrading = get_transient('gmediaUpgrade');
2234
+ if($upgrading){
2235
+ $timeout = time() - $upgrading;
2236
+ } else {
2237
+ $timeout = 0;
2238
+ }
2239
+ if($timeout > 20){
2240
+ require_once(GMEDIA_ABSPATH.'config/update.php');
2241
+ gmedia_db_update();
2242
+ }
2243
+ $result['timeout'] = $timeout;
2244
+
2245
+ if(!empty($info)) {
2246
+ $result['content'] = '<div>' . implode("</div>\n<div>", $info) . '</div>';
2247
+ } elseif($db_version == GMEDIA_DBVERSION) {
2248
+ $result['status'] = 'done';
2249
+ }
2250
+
2251
+ header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2252
+ echo json_encode($result);
2253
+ die();
2254
+
2255
+ }
2256
+
2257
  add_action('wp_ajax_gmedia_module_interaction', 'gmedia_module_interaction');
2258
  add_action('wp_ajax_nopriv_gmedia_module_interaction', 'gmedia_module_interaction');
2259
  function gmedia_module_interaction() {
2330
  die();
2331
  }
2332
 
2333
+ add_action('wp_ajax_load_comments', 'gmedia_module_load_comments');
2334
+ add_action('wp_ajax_nopriv_load_comments', 'gmedia_module_load_comments');
2335
+ function gmedia_module_load_comments() {
2336
+ global $gmCore;
2337
+
2338
+ /* if(empty($_SERVER['HTTP_REFERER'])) {
2339
+ header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2340
+ die();
2341
+ }
2342
+
2343
+ $ref = $_SERVER['HTTP_REFERER'];
2344
+ //$uip = str_replace('.', '', $_SERVER['REMOTE_ADDR'])
2345
+ if((false === strpos($ref, get_home_url())) && (false === strpos($ref, get_site_url()))) {
2346
+ header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2347
+ die();
2348
+ }
2349
+ if(('POST' !== $_SERVER['REQUEST_METHOD']) || !isset($_SERVER['HTTP_HOST']) || !strpos(get_home_url(), $_SERVER['HTTP_HOST'])) {
2350
+ header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
2351
+ die();
2352
+ }*/
2353
+
2354
+ check_ajax_referer('GmediaGallery');
2355
+
2356
+ $data = $gmCore->_post('data', false);
2357
+
2358
+ $post_id = (int)$data['post_id'];
2359
+ if($post_id) {
2360
+ $comments_link = apply_filters('gmedia_comments_link', add_query_arg('comments', 'show', get_permalink($post_id)), $post_id);
2361
+ $comments_count = wp_count_comments($post_id);
2362
+ $comments_count = $comments_count->approved;
2363
+ } else {
2364
+ $comments_link = '//about:blank';
2365
+ $comments_count = 0;
2366
+ }
2367
+
2368
+ $result = array();
2369
+ $result['comments_count'] = $comments_count;
2370
+ $result['content'] = "<iframe class='gmedia-comments' src='{$comments_link}' frameborder='0' allowtransparency='true'>";
2371
+
2372
+ header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
2373
+ echo json_encode($result);
2374
+
2375
+ die();
2376
+ }
2377
+
admin/app.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
3
  die('You are not allowed to call this page directly.');
4
  }
5
 
@@ -8,36 +8,36 @@ if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
8
  *
9
  * @return mixed content
10
  */
11
- function gmediaApp()
12
- {
13
- global $gmCore, $gmProcessor, $gmGallery;
14
 
15
- if (false !== ($force_app_status = $gmCore->_get('force_app_status'))) {
16
  $gm_options = get_option('gmediaOptions');
17
  $gm_options['mobile_app'] = (int)$force_app_status;
18
  update_option('gmediaOptions', $gm_options);
19
  }
20
  $alert = '';
21
  $btn_state = '';
22
- if ('127.0.0.1' == $_SERVER['SERVER_ADDR']) {
23
- $alert = $gmProcessor->alert('danger', __('Your server is not accessable by iOS application', 'grand-media'));
24
  $btn_state = ' disabled';
25
  }
26
 
27
- $email = $gmGallery->options['site_email'] ? $gmGallery->options['site_email'] : get_option('admin_email');
28
- $category = $gmGallery->options['site_category'];
29
- $site_ID = $gmGallery->options['site_ID'];
30
- $mobile_app = (int)$gmGallery->options['mobile_app'];
 
31
 
32
  ?>
33
  <form class="panel panel-default" method="post" id="gm_application">
34
  <div class="panel-heading clearfix">
35
  <div class="btn-toolbar pull-left gm_service_actions">
36
  <div class="btn-group<?php echo $mobile_app? '' : ' hidden' ?>">
37
- <button type="button" name="gmedia_application_deactivate" id="app_deactivate" class="btn btn-danger<?php echo $btn_state; ?>" data-confirm="<?php _e('Disable access to your Gmedia Library via iOS application?') ?>"><?php _e('Disable Service', 'grand-media'); ?></button>
38
- <button type="button" name="gmedia_application_updateinfo" id="app_updateinfo" class="btn btn-primary<?php echo $btn_state; ?>"><?php _e('Update Info', 'grand-media'); ?></button>
39
  </div>
40
- <button type="button" name="gmedia_application_activate" id="app_activate" class="btn btn-primary<?php echo $btn_state . ($mobile_app? ' hidden' : ''); ?>"><?php _e('Enable Service', 'grand-media'); ?></button>
41
  </div>
42
  <?php
43
  wp_nonce_field('GmediaService');
@@ -45,62 +45,56 @@ function gmediaApp()
45
  </div>
46
  <div class="panel-body" id="gmedia-msg-panel"><?php echo $alert; ?></div>
47
  <div class="panel-body" id="gm_application_data">
48
- <?php if (current_user_can('manage_options')) { ?>
49
  <div class="container-fluid">
50
  <div class="row">
51
  <div class="col-xs-7">
 
 
 
 
 
 
 
 
 
 
 
 
52
  <!--<p><?php echo 'Server address: ' . $_SERVER['SERVER_ADDR'];
53
  echo '<br>Remote address: ' . $_SERVER['REMOTE_ADDR'];
54
  ?></p>-->
55
- <p><?php _e('On the right side you can see information about your website that will be used by iOS application, so you\'ll be able to manage your Gmedia Library with your smartphone.', 'grand-media'); ?></p>
56
 
57
  <p><?php _e('Download Gmedia iOS application from the App Store to manage your Gmedia Library from iPhone.', 'grand-media'); ?></p>
58
 
59
- <div class="text-center"><img style="max-width:100%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/img/mobile_app.png"/>
60
- <br/><a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="max-width:100%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/img/appstore_button.png"/></a>
61
  </div>
62
  </div>
63
  <div class="col-xs-5">
64
  <div class="form-group">
65
  <label><?php _e('Email', 'grand-media') ?>:</label>
66
- <input type="text" name="email" class="form-control input-sm" value="<?php echo $email; ?>"/>
67
- </div>
68
- <div class="form-group">
69
- <?php
70
- $term_type = 'gmedia_category';
71
- $gm_terms = $gmGallery->options['taxonomies'][$term_type];
72
-
73
- $terms_category = '';
74
- if (count($gm_terms)) {
75
- foreach ($gm_terms as $term_name => $term_title) {
76
- $selected_option = ($category === $term_name) ? ' selected="selected"' : '';
77
- $terms_category .= '<option' . $selected_option . ' value="' . $term_name . '">' . esc_html($term_title) . '</option>' . "\n";
78
- }
79
- }
80
- ?>
81
- <label><?php _e('Which category fit your site most?', 'grand-media'); ?></label>
82
- <select id="gmedia_category" name="category" class="form-control input-sm">
83
- <option value=""<?php echo $category ? '' : ' selected="selected"'; ?>><?php _e('Uncategorized', 'grand-media'); ?></option>
84
- <?php echo $terms_category; ?>
85
- </select>
86
  </div>
87
  <div class="form-group">
88
  <label><?php _e('Site URL', 'grand-media') ?>:</label>
89
- <input type="text" readonly="readonly" name="url" class="form-control input-sm" value="<?php echo home_url(); ?>"/>
90
  </div>
91
  <div class="form-group">
92
  <label><?php _e('Site Title', 'grand-media') ?>:</label>
93
- <input type="text" readonly="readonly" name="title" class="form-control input-sm" value="<?php bloginfo('name'); ?>"/>
94
  </div>
95
  <div class="form-group">
96
  <label><?php _e('Site Description', 'grand-media') ?>:</label>
97
- <textarea readonly="readonly" rows="2" cols="10" name="description" class="form-control input-sm"><?php bloginfo('description'); ?></textarea>
98
  </div>
 
99
  </div>
100
  </div>
101
  </div>
102
  <script type="text/javascript">
103
- jQuery(function ($) {
104
 
105
  function gmedia_application(service) {
106
  var post_data = {
@@ -109,20 +103,20 @@ function gmediaApp()
109
  data: $('#gm_application_data :input').serialize(),
110
  _wpnonce: $('#_wpnonce').val()
111
  };
112
- $.post(ajaxurl, post_data, function (data, textStatus, jqXHR) {
113
  console.log(data);
114
- if (data.error) {
115
  $('#gmedia-msg-panel').append(data.error);
116
- } else if (data.message) {
117
  $('#gmedia-msg-panel').append(data.message);
118
  }
119
  //noinspection JSUnresolvedVariable
120
- if (parseInt(data.mobile_app)) {
121
  $('.gm_service_actions > .btn-group').removeClass('hidden');
122
- $('#app_activate').addClass('hidden');
123
  } else {
124
  $('.gm_service_actions > .btn-group').addClass('hidden');
125
- $('#app_activate').removeClass('hidden');
126
  }
127
  });
128
  }
@@ -131,8 +125,8 @@ function gmediaApp()
131
  gmedia_application('app_checkstatus');
132
  <?php } ?>
133
 
134
- $('.gm_service_actions button').on('click', function () {
135
- var service = $(this).attr('id');
136
  gmedia_application(service);
137
  });
138
 
1
  <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
3
  die('You are not allowed to call this page directly.');
4
  }
5
 
8
  *
9
  * @return mixed content
10
  */
11
+ function gmediaApp() {
12
+ global $gmCore, $gmGallery;
 
13
 
14
+ if(false !== ($force_app_status = $gmCore->_get('force_app_status'))) {
15
  $gm_options = get_option('gmediaOptions');
16
  $gm_options['mobile_app'] = (int)$force_app_status;
17
  update_option('gmediaOptions', $gm_options);
18
  }
19
  $alert = '';
20
  $btn_state = '';
21
+ if('127.0.0.1' == $_SERVER['SERVER_ADDR']) {
22
+ $alert = $gmCore->alert('danger', __('Your server is not accessable by iOS application', 'grand-media'));
23
  $btn_state = ' disabled';
24
  }
25
 
26
+ $site_email = $gmGallery->options['site_email'];
27
+ $site_title = $gmGallery->options['site_title'];
28
+ $site_description = $gmGallery->options['site_description'];
29
+ $site_ID = $gmGallery->options['site_ID'];
30
+ $mobile_app = (int)$gmGallery->options['mobile_app'];
31
 
32
  ?>
33
  <form class="panel panel-default" method="post" id="gm_application">
34
  <div class="panel-heading clearfix">
35
  <div class="btn-toolbar pull-left gm_service_actions">
36
  <div class="btn-group<?php echo $mobile_app? '' : ' hidden' ?>">
37
+ <button type="button" name="gmedia_application_deactivate" data-action="app_deactivate" class="btn btn-danger<?php echo $btn_state; ?>" data-confirm="<?php _e('Exclude your website from GmediaService?') ?>"><?php _e('Disable GmediaService', 'grand-media'); ?></button>
38
+ <button type="button" name="gmedia_application_updateinfo" data-action="app_updateinfo" class="btn btn-primary<?php echo $btn_state; ?>"><?php _e('Update Info', 'grand-media'); ?></button>
39
  </div>
40
+ <button type="button" name="gmedia_application_activate" data-action="app_activate" class="gmapp_activate btn btn-primary<?php echo $btn_state . ($mobile_app? ' hidden' : ''); ?>"><?php _e('Enable GmediaService', 'grand-media'); ?></button>
41
  </div>
42
  <?php
43
  wp_nonce_field('GmediaService');
45
  </div>
46
  <div class="panel-body" id="gmedia-msg-panel"><?php echo $alert; ?></div>
47
  <div class="panel-body" id="gm_application_data">
48
+ <?php if(current_user_can('manage_options')) { ?>
49
  <div class="container-fluid">
50
  <div class="row">
51
  <div class="col-xs-7">
52
+ <?php /* ?>
53
+ <div class="gm_service_actions">
54
+ <p><button type="button" data-action="app_activate" class="btn btn-primary"><?php _e('Activate GmediaService', 'grand-media'); ?></button>
55
+ <button type="button" data-action="app_deactivate" class="btn btn-primary"><?php _e('Deactivate GmediaService', 'grand-media'); ?></button></p>
56
+
57
+ <p><button type="button" data-action="app_updateinfo" class="btn btn-primary"><?php _e('Update GmediaService', 'grand-media'); ?></button>
58
+ <button type="button" data-action="app_updatecron" class="btn btn-primary"><?php _e('Cron Job GmediaService', 'grand-media'); ?></button></p>
59
+
60
+ <p><button type="button" data-action="app_deactivateplugin" class="btn btn-primary"><?php _e('Deactivate Plugin GmediaService', 'grand-media'); ?></button>
61
+ <button type="button" data-action="app_uninstallplugin" class="btn btn-primary"><?php _e('Uninstall Plugin GmediaService', 'grand-media'); ?></button></p>
62
+ </div>
63
+ <?php */ ?>
64
  <!--<p><?php echo 'Server address: ' . $_SERVER['SERVER_ADDR'];
65
  echo '<br>Remote address: ' . $_SERVER['REMOTE_ADDR'];
66
  ?></p>-->
67
+ <p><?php _e('On the right side you can see information about your website that will be used by GmediaService and iOS application, so you\'ll be able to manage your Gmedia Library with your smartphone and other people can find and view your public collections.', 'grand-media'); ?></p>
68
 
69
  <p><?php _e('Download Gmedia iOS application from the App Store to manage your Gmedia Library from iPhone.', 'grand-media'); ?></p>
70
 
71
+ <div class="text-center"><img style="max-width:100%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/mobile_app.png"/>
72
+ <br/><a target="_blank" href="https://itunes.apple.com/ua/app/gmedia/id947515626?mt=8"><img style="max-width:100%;" src="<?php echo $gmCore->gmedia_url; ?>/admin/assets/img/appstore_button.png"/></a>
73
  </div>
74
  </div>
75
  <div class="col-xs-5">
76
  <div class="form-group">
77
  <label><?php _e('Email', 'grand-media') ?>:</label>
78
+ <input type="text" name="site_email" class="form-control input-sm" value="<?php esc_attr_e($site_email); ?>" placeholder="<?php esc_attr_e(get_option('admin_email')); ?>"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  </div>
80
  <div class="form-group">
81
  <label><?php _e('Site URL', 'grand-media') ?>:</label>
82
+ <input type="text" readonly="readonly" name="site_url" class="form-control input-sm" value="<?php echo home_url(); ?>"/>
83
  </div>
84
  <div class="form-group">
85
  <label><?php _e('Site Title', 'grand-media') ?>:</label>
86
+ <input type="text" name="site_title" class="form-control input-sm" value="<?php esc_attr_e($site_title); ?>" placeholder="<?php esc_attr_e(get_bloginfo('name')); ?>"/>
87
  </div>
88
  <div class="form-group">
89
  <label><?php _e('Site Description', 'grand-media') ?>:</label>
90
+ <textarea rows="2" cols="10" name="site_description" class="form-control input-sm" placeholder="<?php esc_attr_e(get_bloginfo('description')); ?>"><?php esc_html_e($site_description); ?></textarea>
91
  </div>
92
+ <p><?php _e('Also the list of your Gmedia Tags will be shared with GmediaService.') ?></p>
93
  </div>
94
  </div>
95
  </div>
96
  <script type="text/javascript">
97
+ jQuery(function($) {
98
 
99
  function gmedia_application(service) {
100
  var post_data = {
103
  data: $('#gm_application_data :input').serialize(),
104
  _wpnonce: $('#_wpnonce').val()
105
  };
106
+ $.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
107
  console.log(data);
108
+ if(data.error) {
109
  $('#gmedia-msg-panel').append(data.error);
110
+ } else if(data.message) {
111
  $('#gmedia-msg-panel').append(data.message);
112
  }
113
  //noinspection JSUnresolvedVariable
114
+ if(parseInt(data.mobile_app)) {
115
  $('.gm_service_actions > .btn-group').removeClass('hidden');
116
+ $('.gmapp_activate').addClass('hidden');
117
  } else {
118
  $('.gm_service_actions > .btn-group').addClass('hidden');
119
+ $('.gmapp_activate').removeClass('hidden');
120
  }
121
  });
122
  }
125
  gmedia_application('app_checkstatus');
126
  <?php } ?>
127
 
128
+ $('.gm_service_actions button').on('click', function() {
129
+ var service = $(this).attr('data-action');
130
  gmedia_application(service);
131
  });
132
 
admin/assets/css/gmedia.admin.css ADDED
@@ -0,0 +1,1254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ background:#708090;
3
+ }
4
+ #adminmenu #toplevel_page_GrandMedia ul.wp-submenu {
5
+ display:none;
6
+ }
7
+ #wpfooter {
8
+ color:#ffffff;
9
+ }
10
+ #wpfooter a {
11
+ color:lightblue;
12
+ }
13
+ #TB_caption {
14
+ height:auto;
15
+ }
16
+ a {
17
+ color:#0074a2;
18
+ }
19
+ input[type="checkbox"] {
20
+ margin-top:2px;
21
+ margin-right:2px
22
+ }
23
+ input[type="checkbox"], input[type="radio"] {
24
+ height:16px;
25
+ width:16px;
26
+ }
27
+ input::-moz-focus-inner {
28
+ border:0;
29
+ padding:0;
30
+ margin-top:-2px;
31
+ margin-bottom:-2px;
32
+ }
33
+ form,
34
+ .gmedia-admin form { margin:0; }
35
+ legend.label { text-align:left; }
36
+ textarea.vert { resize:vertical; }
37
+ textarea.noResize { resize:none; }
38
+ body.gmedia-busy {
39
+ cursor:wait !important;
40
+ }
41
+ iframe, iframe html {
42
+ background-color:#ffffff;
43
+ }
44
+ body.gmedia-blank {
45
+ background-color:#ffffff;
46
+ height:auto;
47
+ min-height:100%;
48
+ padding:0 0 1px;
49
+ box-sizing:border-box;
50
+ }
51
+ body.gmedia-blank pre {
52
+ margin:0;
53
+ padding:0;
54
+ border:none;
55
+ }
56
+ .gmedia-body div#gm-message {
57
+ position:absolute;
58
+ right:5px;
59
+ top:5px;
60
+ overflow:visible;
61
+ z-index:200;
62
+ }
63
+ .gmedia-body div#gm-message .gm-message {
64
+ text-align:right;
65
+ }
66
+ div#gmedia-container {
67
+ font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
68
+ margin:30px 5px 10px 0;
69
+ position:relative;
70
+ z-index:1;
71
+ direction:ltr;
72
+ min-width:560px;
73
+ }
74
+ div#gmedia-header {
75
+ position:relative;
76
+ padding:1px 1px 10px 1px;
77
+ }
78
+ /*noinspection CssInvalidElement*/
79
+ div#gmedia-logo {
80
+ position:relative;
81
+ margin:0 30px 0 15px;
82
+ font-size:48px;
83
+ text-shadow:1px 1px 4px #000000;
84
+ font-family:Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
85
+ color:#ffffff;
86
+ float:left;
87
+ /*noinspection CssFloatPxLength*/
88
+ -webkit-text-stroke-width:0.7px;
89
+ -webkit-text-stroke-color:#ffffff;
90
+ -webkit-font-smoothing:antialiased;
91
+ -webkit-user-select:none;
92
+ -moz-user-select:none;
93
+ -ms-user-select:none;
94
+ user-select:none;
95
+ cursor:default;
96
+ }
97
+ div#gmedia-logo small {
98
+ display:block;
99
+ font-size:10px;
100
+ margin-top:7px;
101
+ text-align:right;
102
+ -webkit-text-stroke-width:0;
103
+ }
104
+ div#gmedia-header h2 {
105
+ margin:0;
106
+ font:italic 24px/35px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
107
+ color:#ffffff;
108
+ }
109
+ div#gmedia-navbar {
110
+ font-size:14px;
111
+ }
112
+ div.custom-message {
113
+ padding:5px 10px;
114
+ margin:0 0 10px;
115
+ }
116
+ form.gmedia-search-form {
117
+ float:right;
118
+ margin-left:10px;
119
+ margin-bottom:4px;
120
+ white-space:nowrap;
121
+ }
122
+ form.gmedia-search-form .form-group {
123
+ margin:0;
124
+ display:inline-block;
125
+ vertical-align:middle;
126
+ }
127
+ .gmedia-pager {
128
+ margin-bottom:4px;
129
+ }
130
+ form#gmedia-pager {
131
+ float:left;
132
+ width:auto;
133
+ display:block;
134
+ }
135
+ form#gmedia-pager span,
136
+ form#gmedia-pager input {
137
+ width:auto;
138
+ display:inline-block;
139
+ vertical-align:inherit;
140
+ float:none;
141
+ }
142
+ form#gmedia-pager input.pager_current_page {
143
+ padding-left:0;
144
+ padding-right:0;
145
+ text-align:center;
146
+ width:2.5em;
147
+ }
148
+ .txt-lg {
149
+ font-size:120%;
150
+ line-height:50%;
151
+ }
152
+ a.text-danger {
153
+ color:#a94442;
154
+ }
155
+ .btn > input[type="checkbox"] {
156
+ margin-top:0;
157
+ width:16px;
158
+ height:16px;
159
+ }
160
+ .va-middle { vertical-align:middle }
161
+ .dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
162
+ background-color:#e8e8e8;
163
+ }
164
+ .gm-checkgroup {
165
+ margin-right:20px;
166
+ }
167
+ .gm-backfade {
168
+ background-color:rgba(0, 0, 0, 0.1);
169
+ }
170
+ .dropdown-menu > .disabled {
171
+ cursor:not-allowed;
172
+ }
173
+ .dropdown-menu > .disabled > a {
174
+ pointer-events:none;
175
+ }
176
+ .panel-heading-fake { display:none; }
177
+ .panel-floatingHeader .panel-heading-fake,
178
+ .panel-absoluteHeader .panel-heading-fake { display:block; }
179
+ .panel-fixed-header { position:relative; }
180
+ .panel-fixed-header .panel-heading { position:relative; top:0; max-width:100%;
181
+ /*transition:top 0.2s ease-out; -webkit-transition:top 0.2s ease-out;*/
182
+ }
183
+ .panel-floatingHeader .panel-heading {
184
+ position:fixed;
185
+ top:32px;
186
+ z-index:20;
187
+ border-radius:0;
188
+ -webkit-box-shadow:0 5px 10px #888888;
189
+ -moz-box-shadow:0 5px 10px #888888;
190
+ box-shadow:0 5px 10px #888888;
191
+ }
192
+ .panel-absoluteHeader .panel-heading {
193
+ position:absolute;
194
+ z-index:10;
195
+ top:auto;
196
+ bottom:0;
197
+ border-bottom:1px solid transparent;
198
+ border-bottom-right-radius:3px;
199
+ border-bottom-left-radius:3px;
200
+ }
201
+ div#gm-list-table {
202
+ font-size:13px;
203
+ }
204
+ .list-group-item.row {
205
+ position:relative;
206
+ margin-left:0;
207
+ margin-right:0;
208
+ padding-left:0;
209
+ padding-right:0;
210
+ }
211
+ .list-group-item.d-row {
212
+ position:relative;
213
+ color:inherit;
214
+ z-index:1;
215
+ }
216
+ .no-touch div.list-group-item.d-row:hover {
217
+ background-color:#fafafa;
218
+ }
219
+ .no-touch form.list-group-item.d-row:hover {
220
+ background-color:#fcfcfc;
221
+ }
222
+ .list-group-item.d-row.gm-selected {
223
+ color:#444444;
224
+ border-color:#dddddd;
225
+ background-color:rgb(250, 255, 245);
226
+ -webkit-box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
227
+ -moz-box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
228
+ box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
229
+ }
230
+ .no-touch .list-group-item.d-row.gm-selected:hover {
231
+ color:#444444;
232
+ border-color:#dddddd;
233
+ background-color:rgb(245, 255, 240);
234
+ -webkit-box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
235
+ -moz-box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
236
+ box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
237
+ }
238
+ div#gmedia-container .list-group-item-info,
239
+ div#gmedia-container .list-group-item-info:hover {
240
+ background-color:#d9edf7 !important;
241
+ }
242
+ div#gmedia-container .list-group-item-warning,
243
+ div#gmedia-container .list-group-item-warning:hover {
244
+ background-color:#fcf8e3 !important;
245
+ }
246
+ div#gmedia-container .item-after-limit {
247
+ filter:blur(1px);
248
+ -webkit-filter:blur(1px);
249
+ -moz-filter:blur(1px);
250
+ -o-filter:blur(1px);
251
+ -ms-filter:blur(1px);
252
+ filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius='1');
253
+ }
254
+ .gm-img-thumbnail:not(.item-after-limit) + .item-after-limit {
255
+ clear:left;
256
+ }
257
+ .bg-status-private {
258
+ background-color:#d9edf7;
259
+ -webkit-box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
260
+ -moz-box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
261
+ box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
262
+ }
263
+ .bg-status-draft {
264
+ background-color:#fcf8e3;
265
+ -webkit-box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
266
+ -moz-box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
267
+ box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
268
+ }
269
+ .form-group .gmpost-com-count {font-size:16px;}
270
+ .gmpost-com-count:hover {text-decoration:none}
271
+ label.cb_media-object-gallery {
272
+ width:40px;
273
+ position:absolute;
274
+ left:5px;
275
+ top:0; bottom:0;
276
+ text-align:center;
277
+ }
278
+ .d-row .thumbnail {
279
+ margin-bottom:0;
280
+ }
281
+ .gm-selected .thumbnail {
282
+ border-color:#428bca;
283
+ }
284
+ .thumbnail {
285
+ position:relative;
286
+ display:inline-block;
287
+ max-width:100%;
288
+ }
289
+ .display-as-grid .gm-item-cell {
290
+ padding:15px;
291
+ }
292
+ .display-as-grid div.thumbnail {
293
+ cursor:pointer;
294
+ position:relative;
295
+ display:block;
296
+ border-radius:0;
297
+ margin:0;
298
+ padding:0;
299
+ }
300
+ .display-as-grid div.thumbnail:before {
301
+ content:"";
302
+ display:block;
303
+ padding-top:100%;
304
+ }
305
+ .display-as-grid .gm-selected div.thumbnail {
306
+ -webkit-box-shadow:0 0 0 7px #1e8cbe;
307
+ -moz-box-shadow:0 0 0 7px #1e8cbe;
308
+ box-shadow:0 0 0 7px #1e8cbe;
309
+ }
310
+ .display-as-grid div.thumbnail .cb_media-object {
311
+ bottom:0px;
312
+ left:0px;
313
+ overflow:hidden;
314
+ position:absolute;
315
+ right:0px;
316
+ top:0px;
317
+ text-align:center;
318
+ margin:0;
319
+ }
320
+ .display-as-grid div.thumbnail .gm-cell-more {
321
+ position:absolute;
322
+ left:0; top:0; right:0;
323
+ background:rgba(256, 256, 256, 0.6);
324
+ color:#000000;
325
+ cursor:auto;
326
+ }
327
+ .display-as-grid div.thumbnail .gm-cell-title {
328
+ overflow:hidden;
329
+ font-size:12px;
330
+ font-weight:bold;
331
+ padding:5px 25px 4px 7px;
332
+ cursor:pointer;
333
+ }
334
+ .display-as-grid div.thumbnail .gm-cell-title span {
335
+ display:block;
336
+ width:100%;
337
+ white-space:nowrap;
338
+ text-overflow:ellipsis;
339
+ overflow:hidden;
340
+ }
341
+ .display-as-grid div.thumbnail .gm-cell-more-btn {
342
+ position:absolute;
343
+ top:7px; right:2px;
344
+ padding:0 5px;
345
+ cursor:pointer;
346
+ }
347
+ .display-as-grid div.thumbnail .gm-cell-more-content {
348
+ padding:0 5px;
349
+ height:0;
350
+ overflow:hidden;
351
+ transition:all 0.2s easy-out;
352
+ font-size:11px;
353
+ }
354
+ .display-as-grid div.thumbnail .gm-cell-more-content .gmedia-actions {
355
+ display:none;
356
+ }
357
+ .display-as-grid div.thumbnail .gm-cell-more:hover,
358
+ .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active {
359
+ z-index:10;
360
+ -webkit-box-shadow:0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
361
+ -moz-box-shadow:0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
362
+ box-shadow:0 0 0 1px #dddddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
363
+ }
364
+ .display-as-grid div.thumbnail .gm-cell-more:hover {
365
+ z-index:11;
366
+ }
367
+ .display-as-grid div.thumbnail .gm-cell-more:hover > div {
368
+ background:rgba(256, 256, 256, 0.7);
369
+ }
370
+ .display-as-grid div.thumbnail .gm-cell-more-active .gm-cell-more-content .gmedia-actions {
371
+ display:block;
372
+ }
373
+ .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active > div {
374
+ background:rgba(256, 256, 256, 0.9);
375
+ }
376
+ .display-as-grid div.thumbnail .gm-cell-more:hover .gm-cell-more-content,
377
+ .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active .gm-cell-more-content {
378
+ height:auto;
379
+ }
380
+ .display-as-grid div.thumbnail .gm-cell-more-content p {
381
+ font-size:11px;
382
+ }
383
+ .display-as-grid div.thumbnail .cb_media-object .centered {
384
+ height:100%;
385
+ left:0;
386
+ position:absolute;
387
+ top:0;
388
+ transform:translate(50%, 50%);
389
+ width:100%;
390
+ }
391
+ .display-as-grid div.thumbnail.landscape .cb_media-object .centered {
392
+ transform:translate(50%, 50.5%);
393
+ }
394
+ .display-as-grid div.thumbnail .cb_media-object img {
395
+ left:0;
396
+ position:absolute;
397
+ top:0;
398
+ transform:translate(-50%, -50%);
399
+ }
400
+ .display-as-grid div.thumbnail.landscape img {
401
+ height:101%;
402
+ width:auto;
403
+ }
404
+ .display-as-grid div.thumbnail.portrait img {
405
+ height:auto;
406
+ width:100%;
407
+ }
408
+ .display-as-grid.invert-ratio div.thumbnail.landscape img {
409
+ height:auto;
410
+ width:101%;
411
+ }
412
+ .display-as-grid.invert-ratio div.thumbnail.portrait img {
413
+ height:101%;
414
+ width:auto;
415
+ }
416
+ .thumbnail .gmedia-typethumb {
417
+ position:absolute;
418
+ right:5px;
419
+ bottom:7px;
420
+ height:75px;
421
+ max-height:60%;
422
+ width:auto;
423
+ }
424
+ .thumbwrap { position:relative; margin-bottom:5px; }
425
+ .gm-stack { position:absolute; right:-8px; bottom:-8px; padding:5px; margin:0; border:1px solid #1e8cbe; background-color:#ffffff; border-width:1px 0 0 1px; }
426
+ .gm-stack input{ margin:0; padding:0; }
427
+ .thumbwrap .gm-stack { right:1px; bottom:1px; border:1px solid #dddddd; border-radius:5px 0 5px 0; border-right-color:transparent; border-bottom-color:transparent; border-width:1px; }
428
+ .thumbwrap .cb_media-object { width:100%; margin:0; display:flex; }
429
+ .cb_media-object .thumbnail {
430
+ width:100%;
431
+ }
432
+ .media-title {
433
+ font-weight:bold;
434
+ font-size:15px;
435
+ }
436
+ .media-caption:empty { display:none; }
437
+ .media-caption.in-library {
438
+ max-height:215px;
439
+ }
440
+ .media-caption {
441
+ background-color:#f5f5f5;
442
+ border:1px solid #cccccc;
443
+ border-radius:4px;
444
+ padding:5px 7px;
445
+ margin:0 -6px 5px;
446
+ overflow:auto;
447
+ word-break:normal;
448
+ word-wrap:break-word;
449
+ max-height:210px;
450
+ }
451
+ .media-body .media-caption {
452
+ margin:0;
453
+ }
454
+ .media-meta {
455
+ width:100%;
456
+ overflow:hidden;
457
+ text-overflow:ellipsis; /*white-space:nowrap;*/
458
+ }
459
+ .media-meta .gm_gallery_source { font-weight:bold; }
460
+ .media-meta .label-default {
461
+ background-color:#eeeeee;
462
+ color:#444444;
463
+ }
464
+ .gmedia_id {
465
+ position:absolute;
466
+ right:10px;
467
+ top:10px;
468
+ }
469
+ .no-touch .gmedia_id,
470
+ .no-touch .term_id {
471
+ display:none;
472
+ }
473
+ .term_id {
474
+ position:absolute;
475
+ right:0;
476
+ top:0;
477
+ padding:10px 10px 0 0;
478
+ background-color:#ffffff;
479
+ display:none;
480
+ height:100%;
481
+ -webkit-box-shadow:-10px 0 5px -2px #ffffff;
482
+ -moz-box-shadow:-10px 0 5px -2px #ffffff;
483
+ box-shadow:-10px 0 5px -2px #ffffff;
484
+ z-index:1000;
485
+ }
486
+ .term-list-item.gm-selected .term_id {
487
+ display:block;
488
+ }
489
+ .no-touch #gm-list-table .list-group-item:hover .gmedia_id,
490
+ .no-touch #gm-list-table .list-group-item:hover .term_id {
491
+ display:block;
492
+ }
493
+ #gm-list-table .hidden {
494
+ display:none !important;
495
+ visibility:hidden !important;
496
+ }
497
+ form#adv-settings .form-inline .form-group {
498
+ margin-right:20px;
499
+ }
500
+ form.changed {
501
+ }
502
+ form.changed.saved {
503
+ }
504
+ form.changed .gm-last-edited {
505
+ text-decoration:line-through;
506
+ }
507
+ .selectize-input.full input {
508
+ width:4px !important;
509
+ }
510
+ .rel-selected-hide {
511
+ display:none;
512
+ }
513
+ .plupload_wrapper {
514
+ min-width:unset;
515
+ }
516
+ .gmAddMedia {
517
+ padding:0;
518
+ }
519
+ div#pluploadUploader {
520
+ padding:0;
521
+ }
522
+ div#pluploadUploader * {
523
+ box-sizing:border-box;
524
+ }
525
+ div#pluploadUploader > div > div * {
526
+ box-sizing:content-box;
527
+ }
528
+ .plupload_container {
529
+ padding:0;
530
+ }
531
+ div#pluploadUploader_container {
532
+ min-height:450px;
533
+ border-bottom-right-radius:4px;
534
+ }
535
+ div#pluploadUploader_container .plupload_filelist_footer {
536
+ border-bottom-right-radius:4px;
537
+ font-size:11px;
538
+ white-space:nowrap;
539
+ }
540
+ div#pluploadUploader_buttons { margin-bottom:5px; }
541
+ div.plupload_started { float:left; }
542
+ div.panel-body, div#gmedia-msg-panel {
543
+ -webkit-transition:all .2s ease-in-out;
544
+ transition:all .2s ease-in-out;
545
+ }
546
+ div.panel-body:empty, div#gmedia-msg-panel:empty {
547
+ padding:0;
548
+ }
549
+ div#gmedia-msg-panel .alert {
550
+ padding:2px 35px 2px 12px;
551
+ margin-bottom:5px;
552
+ }
553
+ .plupload_content li {
554
+ margin-bottom:0;
555
+ }
556
+ .progress {
557
+ position:relative;
558
+ white-space:nowrap;
559
+ font-size:12px;
560
+ line-height:20px;
561
+ }
562
+ .progress-bar {
563
+ position:absolute;
564
+ overflow:hidden;
565
+ }
566
+ .tab-inside {
567
+ padding:10px;
568
+ position:relative;
569
+ }
570
+ .tab-footer {
571
+ border-top:1px solid #dddddd;
572
+ padding:20px 10px 0;
573
+ }
574
+ .selectize-control.input-sm .selectize-input {
575
+ min-height:30px;
576
+ padding:2px 10px;
577
+ font-size:12px;
578
+ line-height:1.9;
579
+ border-radius:3px;
580
+ }
581
+ .selectize-control.multi .selectize-input.has-items {
582
+ padding-top:2px;
583
+ }
584
+ .selectize-control.input-sm .selectize-input input {
585
+ font-size:12px;
586
+ }
587
+ .selectize-control.input-sm .selectize-input:after {
588
+ right:10px;
589
+ }
590
+ .selectize-control.input-sm .selectize-input > div {
591
+ line-height:146%;
592
+ }
593
+ .term-list-item {
594
+ padding-top:0;
595
+ padding-bottom:0;
596
+ z-index:1;
597
+ }
598
+ #gmedia-container .cb_term-object { min-height:60px; }
599
+ #gmedia-container .gmedia_album .cb_term-object { min-height:78px; }
600
+ .object-actions { text-align:right; font-size:16px; }
601
+ .object-actions.gallery-object-actions { text-align:left; margin-bottom:5px; }
602
+ .object-actions > * { margin:0 0 0 10px; vertical-align:middle; display:inline-block; }
603
+ .object-actions a:hover { text-decoration:none; }
604
+ .gm_filter_in_lib { border:1px solid; border-radius:4px; font-size:14px; line-height:14px; padding:0 2px 0 4px; }
605
+ .gm_term_count { font-size:13px; font-weight:bold; text-decoration:none; vertical-align:bottom; }
606
+ a.trash-icon:hover { color:#843534; }
607
+ .action-inactive { color:#b8b8b8; }
608
+ .action-inactive:hover { color:#b8b8b8; }
609
+ .term-list-item .term-label .checkbox {
610
+ padding-left:35px;
611
+ }
612
+ .term-list-item .term-label .checkbox > input {
613
+ margin-left:-35px;
614
+ }
615
+ .term-list-item .checkbox input {
616
+ margin-top:0;
617
+ margin-right:15px;
618
+ }
619
+ .term-list-item .term-description {
620
+ padding:0;
621
+ white-space:nowrap;
622
+ overflow:hidden;
623
+ color:#444444;
624
+ text-overflow:ellipsis;
625
+ }
626
+ .term-list-item .term-description:empty {
627
+ padding:0;
628
+ }
629
+ .term-list-item .term-images {
630
+ padding-top:5px;
631
+ padding-bottom:5px;
632
+ overflow:hidden;
633
+ white-space:nowrap;
634
+ position:relative;
635
+ z-index:1;
636
+ }
637
+ .term-list-item .term-images img {
638
+ position:relative;
639
+ height:50px;
640
+ width:auto;
641
+ background-color:#ffffff;
642
+ }
643
+ .term-list-item .term_name {
644
+ margin-right:10px;
645
+ }
646
+ .gmedia_album .term-list-item .term-images img { height:68px; }
647
+ .gmedia_album .term-list-item .term_name { font-size:14px; font-weight:bold; }
648
+ .term-list-item .term_info_author {
649
+ font-size:80%;
650
+ white-space:nowrap;
651
+ color:#444444;
652
+ }
653
+ .no-touch .term-list-item .term-images img:hover {
654
+ z-index:100 !important;
655
+ }
656
+ .edit_tag_form {
657
+ display:inline-block;
658
+ margin-left:-5px;
659
+ margin-bottom:-1px;
660
+ margin-top:-1px;
661
+ }
662
+ .edit_tag_form input.edit_tag_input {
663
+ padding:0 5px;
664
+ border-width:0 0 1px 0;
665
+ margin:0;
666
+ }
667
+ a.edit_tag_save.btn {
668
+ padding-top:0;
669
+ padding-bottom:0;
670
+ }
671
+ .no-touch a.edit_tag_save.btn-link:hover {
672
+ text-decoration:none;
673
+ }
674
+ .gm-img-thumbnail {
675
+ display:inline-block;
676
+ float:left;
677
+ position:relative;
678
+ margin-right:5px;
679
+ margin-bottom:25px;
680
+ max-width:100%;
681
+ height:auto;
682
+ padding:4px;
683
+ line-height:1.428571429;
684
+ background-color:#ffffff;
685
+ border:1px solid #dddddd;
686
+ border-radius:4px;
687
+ }
688
+ .gm-img-thumbnail input {
689
+ display:block;
690
+ line-height:120%;
691
+ position:absolute;
692
+ right:-1px;
693
+ top:-1px;
694
+ width:42px;
695
+ padding:0 2px;
696
+ text-align:center;
697
+ border-radius:4px;
698
+ opacity:0.9;
699
+ }
700
+ .gm-img-thumbnail input:focus {
701
+ opacity:1;
702
+ }
703
+ .gm-img-thumbnail .label {
704
+ position:absolute;
705
+ left:0;
706
+ bottom:0;
707
+ font-weight:normal;
708
+ line-height:120%;
709
+ pointer-events:none;
710
+ }
711
+ .gm-img-thumbnail .gm-img-thumb-title {
712
+ position:absolute;
713
+ left:0;
714
+ top:100%;
715
+ font-size:90%;
716
+ line-height:120%;
717
+ width:100%;
718
+ padding:3px;
719
+ text-overflow:ellipsis;
720
+ white-space:nowrap;
721
+ overflow:hidden;
722
+ text-align:left;
723
+ }
724
+ .gm-img-thumbnail.ui-sortable-helper .gm-img-thumb-title {
725
+ visibility:hidden;
726
+ }
727
+ .ui-highlight-placeholder {
728
+ border:1px solid #0074a2;
729
+ }
730
+ .termItems {
731
+ position:relative;
732
+ }
733
+ .termItems .gm-img-thumbnail {
734
+ width:160px;
735
+ height:120px;
736
+ text-align:center;
737
+ line-height:107px;
738
+ }
739
+ #gmedia-edit-term .gm-img-thumbnail {
740
+ height:121px;
741
+ text-align:center;
742
+ margin:0;
743
+ line-height:107px;
744
+ }
745
+ .gm-img-thumbnail img {
746
+ height:auto;
747
+ width:auto;
748
+ max-width:100%;
749
+ max-height:100%;
750
+ display:inline-block;
751
+ vertical-align:middle;
752
+ }
753
+ .choose-module {
754
+ padding:10px;
755
+ cursor:pointer;
756
+ overflow:hidden;
757
+ margin:0;
758
+ }
759
+ .no-touch .choose-module:hover {
760
+ background-color:#d0e9c6;
761
+ }
762
+ .choose-module .thumbnail {
763
+ margin-bottom:0;
764
+ }
765
+ .media {
766
+ overflow:hidden;
767
+ }
768
+ .media > .thumbnail.pull-left {
769
+ padding:4px;
770
+ margin-right:10px
771
+ }
772
+ .presetlist a {
773
+ position:relative;
774
+ padding-right:30px;
775
+ }
776
+ .delpreset {
777
+ position:absolute;
778
+ right:0;
779
+ top:0;
780
+ bottom:0;
781
+ padding:0.8em 7px 0;
782
+ line-height:100%;
783
+ }
784
+ .delpreset span {
785
+ line-height:100%;
786
+ font-size:94%;
787
+ padding:0 5px 2px;
788
+ cursor:pointer;
789
+ }
790
+ body#media-upload {
791
+ height:100%;
792
+ overflow:auto;
793
+ margin:0;
794
+ padding:0;
795
+ background:#ffffff;
796
+ }
797
+ body#media-upload .panel {
798
+ position:relative;
799
+ height:100%;
800
+ overflow:auto;
801
+ margin:0;
802
+ border-radius:0;
803
+ border-top:none;
804
+ }
805
+ body#media-upload .panel-heading {
806
+ position:relative;
807
+ z-index:100;
808
+ }
809
+ body#media-upload .panel-body {
810
+ position:absolute;
811
+ top:55px;
812
+ bottom:0;
813
+ width:100%;
814
+ overflow:hidden;
815
+ z-index:50;
816
+ padding-top:0;
817
+ padding-bottom:0;
818
+ }
819
+ body#media-upload .panel-body > .row {
820
+ height:100%;
821
+ }
822
+ body#media-upload .panel-body > .row > div {
823
+ height:100%;
824
+ overflow:auto;
825
+ padding-top:15px;
826
+ padding-bottom:15px;
827
+ }
828
+ body#media-upload .panel-body .list-group-item {
829
+ border-width:0;
830
+ border-top-width:1px;
831
+ margin:0;
832
+ }
833
+ body#media-upload .panel-body .list-group-item:first-child {
834
+ border-width:0;
835
+ }
836
+ body#media-upload .term-list-item .term-images img {
837
+ height:30px;
838
+ }
839
+ body#media-upload .term-list-item .term-label .no-checkbox {
840
+ display:inline-block;
841
+ width:100%;
842
+ margin:10px 0;
843
+ }
844
+ body#media-upload .term-list-item .term-info {
845
+ display:none;
846
+ }
847
+ .blank-aligner {
848
+ display:inline-block;
849
+ height:40px;
850
+ vertical-align:middle;
851
+ width:1px;
852
+ overflow:hidden;
853
+ margin-right:-2em;
854
+ }
855
+ body#media-upload .media-upload-sidebar {
856
+ border-left:1px solid #cccccc;
857
+ background-color:#eeeeee;
858
+ padding:0 !important;
859
+ position:relative;
860
+ }
861
+ body#media-upload .media-upload-sidebar form {
862
+ display:-webkit-box;
863
+ display:-moz-box;
864
+ display:-ms-flexbox;
865
+ display:-webkit-flex;
866
+ display:flex;
867
+ -webkit-flex-direction:column;
868
+ -moz-flex-direction:column;
869
+ -ms-flex-direction:column;
870
+ flex-direction:column;
871
+ height:100%;
872
+ width:100%;
873
+ }
874
+ body#media-upload .media-upload-sidebar .media-upload-form-container {
875
+ -webkit-box-flex:1 auto;
876
+ -moz-box-flex:1 auto;
877
+ -webkit-flex:1 auto;
878
+ -ms-flex:1 auto;
879
+ flex:1 auto;
880
+ overflow:auto;
881
+ padding:15px;
882
+ }
883
+ body#media-upload .media-upload-sidebar .panel-footer {
884
+ min-height:57px;
885
+ }
886
+ body#media-upload .thumbnail {
887
+ margin:0 5px 5px 0;
888
+ position:relative;
889
+ display:inline-block;
890
+ }
891
+ body#media-upload .thumbnail.active {
892
+ background-color:lightblue;
893
+ border-color:cadetblue;
894
+ }
895
+ body#media-upload .thumbnail .glyphicon {
896
+ display:none;
897
+ position:absolute;
898
+ right:-3px;
899
+ top:-7px;
900
+ font-size:30px;
901
+ }
902
+ body#media-upload .thumbnail.active .glyphicon {
903
+ display:inline-block;
904
+ }
905
+ body#media-upload .plupload_wrapper {
906
+ height:100%;
907
+ box-sizing:border-box;
908
+ }
909
+ .addtags-gap { height:200px; }
910
+ body#media-upload div#pluploadUploader .plupload_container {
911
+ height:100%;
912
+ min-height:inherit !important;
913
+ }
914
+ body#media-upload .ui-resizable-handle {
915
+ display:none !important;
916
+ bottom:-1px;
917
+ }
918
+ #gmedia-post-thumbnail {
919
+ font-size:12px;
920
+ padding:0;
921
+ display:inline;
922
+ white-space:normal;
923
+ }
924
+ body.gmedia-blank.gmedia_image_editor {
925
+ height:100%;
926
+ overflow:auto;
927
+ margin:0;
928
+ padding:0
929
+ }
930
+ body.gmedia-blank.gmedia_image_editor .panel,
931
+ body.gmedia-blank.gmedia_map_editor .panel {
932
+ position:relative;
933
+ height:100%;
934
+ overflow:auto;
935
+ margin:0;
936
+ }
937
+ body.gmedia-blank .panel-heading {
938
+ position:relative;
939
+ z-index:100;
940
+ }
941
+ body.gmedia-blank.gmedia_image_editor .panel-body {
942
+ position:absolute;
943
+ top:55px;
944
+ bottom:0;
945
+ width:100%;
946
+ overflow:hidden;
947
+ z-index:50;
948
+ padding-top:0;
949
+ padding-bottom:0;
950
+ }
951
+ body.gmedia-blank.gmedia_image_editor .panel-body .row {
952
+ height:100%;
953
+ }
954
+ body.gmedia-blank.gmedia_image_editor .panel-body .row > div {
955
+ height:100%;
956
+ overflow:auto;
957
+ padding-top:15px;
958
+ padding-bottom:15px;
959
+ }
960
+ body.gmedia-blank .media-edit-sidebar {
961
+ border-left:1px solid #cccccc;
962
+ background-color:#eeeeee;
963
+ padding:0 0 55px 0 !important;
964
+ position:relative;
965
+ }
966
+ body.gmedia-blank #media-edit-form-container {
967
+ height:100%;
968
+ overflow:auto;
969
+ padding:15px;
970
+ }
971
+ body.gmedia-blank .media-edit-sidebar .panel-footer {
972
+ position:absolute;
973
+ left:0;
974
+ bottom:0;
975
+ right:0;
976
+ }
977
+ #map-floating-panel {
978
+ position:absolute;
979
+ top:15px;
980
+ right:15px;
981
+ z-index:5;
982
+ background-color:#ffffff;
983
+ padding:0 0 5px 5px;
984
+ width:250px;
985
+ }
986
+ #gallery_preview_ {
987
+ width:200%;
988
+ height:800px;
989
+ margin-bottom:-400px;
990
+ overflow:auto;
991
+ -moz-transform:scale(0.5, 0.5);
992
+ -webkit-transform:scale(0.5, 0.5);
993
+ -o-transform:scale(0.5, 0.5);
994
+ -ms-transform:scale(0.5, 0.5);
995
+ transform:scale(0.5, 0.5);
996
+ -moz-transform-origin:top left;
997
+ -webkit-transform-origin:top left;
998
+ -o-transform-origin:top left;
999
+ -ms-transform-origin:top left;
1000
+ transform-origin:top left;
1001
+ border:solid #cccccc 2px;
1002
+ }
1003
+ #gallery_preview {
1004
+ width:100%;
1005
+ height:600px;
1006
+ border:solid #cccccc 1px;
1007
+ overflow:auto;
1008
+ }
1009
+ #adv-settings {
1010
+ overflow:hidden;
1011
+ }
1012
+ #screen-meta .form-group {
1013
+ padding-bottom:10px;
1014
+ }
1015
+ #previewModal {
1016
+ z-index:9999;
1017
+ overflow-x:auto;
1018
+ }
1019
+ input.sharelink[readonly] { cursor:text; }
1020
+ fieldset.gmediacustomstuff { margin:0 0 10px; padding:.35em .625em .4em; position:relative; border:1px solid silver }
1021
+ .delete-custom-field { margin:4px 2px 0; cursor:pointer; }
1022
+ .newcustomfield-modal { position:absolute; bottom:-0.6em; right:8px; font-size:95%; }
1023
+ @media (min-width:782px) {
1024
+ div.modal {
1025
+ top:32px;
1026
+ }
1027
+ div#termsModal .modal-dialog {
1028
+ width:350px;
1029
+ }
1030
+
1031
+ }
1032
+ @media (max-width:600px) {
1033
+ .panel-floatingHeader .panel-heading,
1034
+ .panel-absoluteHeader .panel-heading {
1035
+ position:static;
1036
+ box-shadow:none;
1037
+ }
1038
+ .panel-floatingHeader .panel-heading-fake, .panel-absoluteHeader .panel-heading-fake {
1039
+ display:none;
1040
+ }
1041
+ }
1042
+ @media (max-width:782px) {
1043
+ .panel-floatingHeader .panel-heading {
1044
+ top:46px;
1045
+ }
1046
+ div#wpwrap {
1047
+ background:#708090;
1048
+ }
1049
+ div#wpbody select.input-sm {
1050
+ height:30px;
1051
+ font-size:12px;
1052
+ }
1053
+ #adminmenu #toplevel_page_GrandMedia ul.wp-submenu {
1054
+ display:block;
1055
+ }
1056
+ .media-body { display:block; }
1057
+ .show-settings-link { display:none; }
1058
+ }
1059
+ @media (max-width:991px) {
1060
+ body#media-upload .panel-body > #gmUpload.row {
1061
+ overflow-y:auto;
1062
+ }
1063
+ body#media-upload .panel-body > #gmUpload.row > div {
1064
+ height:auto;
1065
+ }
1066
+ body#media-upload .plupload_wrapper {
1067
+ height:auto;
1068
+ }
1069
+ body#media-upload div#pluploadUploader .plupload_container {
1070
+ height:auto;
1071
+ min-height:300px !important;
1072
+ }
1073
+ }
1074
+ /*@-moz-document url-prefix() {
1075
+ a.btn, span.btn {
1076
+ line-height:1.56;
1077
+ }
1078
+ }*/
1079
+
1080
+ /* custom inclusion of right, left tabs */
1081
+ .tabs-right > .nav-tabs,
1082
+ .tabs-left > .nav-tabs {
1083
+ border-bottom:0;
1084
+ }
1085
+ .gm-tab-content > .tab-pane,
1086
+ .pill-content > .pill-pane {
1087
+ display:none;
1088
+ }
1089
+ .gm-tab-content > .active,
1090
+ .pill-content > .active {
1091
+ display:block;
1092
+ }
1093
+ .tabs-left > .nav-tabs > li,
1094
+ .tabs-right > .nav-tabs > li {
1095
+ float:none;
1096
+ }
1097
+ .tabs-left > .nav-tabs > li > a,
1098
+ .tabs-right > .nav-tabs > li > a {
1099
+ min-width:74px;
1100
+ margin-right:0;
1101
+ margin-bottom:3px;
1102
+ }
1103
+ .tabs-left > .nav-tabs {
1104
+ float:left;
1105
+ margin-right:19px;
1106
+ border-right:1px solid #dddddd;
1107
+ }
1108
+ .tabs-left > .nav-tabs > li > a {
1109
+ margin-right:-1px;
1110
+ -webkit-border-radius:4px 0 0 4px;
1111
+ -moz-border-radius:4px 0 0 4px;
1112
+ border-radius:4px 0 0 4px;
1113
+ }
1114
+ .no-touch .tabs-left > .nav-tabs > li > a:hover,
1115
+ .tabs-left > .nav-tabs > li > a:focus {
1116
+ border-color:#eeeeee #dddddd #eeeeee #eeeeee;
1117
+ }
1118
+ .tabs-left > .nav-tabs .active > a,
1119
+ .no-touch .tabs-left > .nav-tabs .active > a:hover,
1120
+ .tabs-left > .nav-tabs .active > a:focus {
1121
+ border-color:#dddddd transparent #dddddd #dddddd;
1122
+ *border-right-color:#ffffff;
1123
+ }
1124
+ .tabs-right > .nav-tabs {
1125
+ float:right;
1126
+ margin-left:19px;
1127
+ border-left:1px solid #dddddd;
1128
+ }
1129
+ .tabs-right > .nav-tabs > li > a {
1130
+ margin-left:-1px;
1131
+ -webkit-border-radius:0 4px 4px 0;
1132
+ -moz-border-radius:0 4px 4px 0;
1133
+ border-radius:0 4px 4px 0;
1134
+ }
1135
+ .no-touch .tabs-right > .nav-tabs > li > a:hover,
1136
+ .tabs-right > .nav-tabs > li > a:focus {
1137
+ border-color:#eeeeee #eeeeee #eeeeee #dddddd;
1138
+ }
1139
+ .tabs-right > .nav-tabs .active > a,
1140
+ .no-touch .tabs-right > .nav-tabs .active > a:hover,
1141
+ .tabs-right > .nav-tabs .active > a:focus {
1142
+ border-color:#dddddd #dddddd #dddddd transparent;
1143
+ *border-left-color:#ffffff;
1144
+ }
1145
+ /* custom *-xs size for form elements */
1146
+ input[type="date"].input-xs,
1147
+ input[type="time"].input-xs,
1148
+ input[type="datetime-local"].input-xs,
1149
+ input[type="month"].input-xs,
1150
+ .input-group-xs input[type="date"],
1151
+ .input-group-xs input[type="time"],
1152
+ .input-group-xs input[type="datetime-local"],
1153
+ .input-group-xs input[type="month"] {
1154
+ line-height:22px;
1155
+ }
1156
+ .form-control-static.input-xs {
1157
+ padding-right:0;
1158
+ padding-left:0;
1159
+ }
1160
+ .input-xs {
1161
+ height:22px;
1162
+ padding:1px 5px !important;
1163
+ font-size:12px;
1164
+ line-height:1.5;
1165
+ border-radius:3px;
1166
+ }
1167
+ select.input-xs {
1168
+ height:22px;
1169
+ line-height:22px;
1170
+ }
1171
+ textarea.input-xs,
1172
+ select[multiple].input-xs {
1173
+ height:auto;
1174
+ }
1175
+ .form-group-xs .form-control {
1176
+ height:22px;
1177
+ padding:1px 5px;
1178
+ font-size:12px;
1179
+ line-height:1.5;
1180
+ border-radius:3px;
1181
+ }
1182
+ select.form-group-xs .form-control {
1183
+ height:22px;
1184
+ line-height:22px;
1185
+ }
1186
+ textarea.form-group-xs .form-control,
1187
+ select[multiple].form-group-xs .form-control {
1188
+ height:auto;
1189
+ }
1190
+ .form-group-xs .form-control-static {
1191
+ height:22px;
1192
+ min-height:25px;
1193
+ padding:1px 5px;
1194
+ font-size:12px;
1195
+ line-height:1.5;
1196
+ }
1197
+ .input-xs + .form-control-feedback {
1198
+ width:22px;
1199
+ height:22px;
1200
+ line-height:22px;
1201
+ }
1202
+ @media (min-width:768px) {
1203
+ .form-horizontal .form-group-xs .control-label {
1204
+ padding-top:4px;
1205
+ }
1206
+ }
1207
+ .input-group-xs > .form-control,
1208
+ .input-group-xs > .input-group-addon,
1209
+ .input-group-xs > .input-group-btn > .btn {
1210
+ height:22px;
1211
+ padding:1px 5px;
1212
+ font-size:12px;
1213
+ line-height:1.5;
1214
+ border-radius:3px;
1215
+ }
1216
+ select.input-group-xs > .form-control,
1217
+ select.input-group-xs > .input-group-addon,
1218
+ select.input-group-xs > .input-group-btn > .btn {
1219
+ height:22px;
1220
+ line-height:22px;
1221
+ }
1222
+ textarea.input-group-xs > .form-control,
1223
+ textarea.input-group-xs > .input-group-addon,
1224
+ textarea.input-group-xs > .input-group-btn > .btn,
1225
+ select[multiple].input-group-xs > .form-control,
1226
+ select[multiple].input-group-xs > .input-group-addon,
1227
+ select[multiple].input-group-xs > .input-group-btn > .btn {
1228
+ height:auto;
1229
+ }
1230
+ .input-group-addon.input-xs {
1231
+ padding:1px 5px;
1232
+ font-size:12px;
1233
+ border-radius:3px;
1234
+ }
1235
+ .input-group .form-control:first-child,
1236
+ .input-group-addon:first-child,
1237
+ .input-group-btn:first-child > .btn,
1238
+ .input-group-btn:first-child > .btn-group > .btn,
1239
+ .input-group-btn:first-child > .dropdown-toggle,
1240
+ .input-group-btn:last-child > .btn-group:not(:last-child) > .btn,
1241
+ .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle) {
1242
+ border-bottom-right-radius:0;
1243
+ border-top-right-radius:0;
1244
+ }
1245
+ .input-group .form-control:last-child,
1246
+ .input-group-addon:last-child,
1247
+ .input-group-btn:first-child > .btn-group:not(:first-child) > .btn,
1248
+ .input-group-btn:first-child > .btn:not(:first-child),
1249
+ .input-group-btn:last-child > .btn,
1250
+ .input-group-btn:last-child > .btn-group > .btn,
1251
+ .input-group-btn:last-child > .dropdown-toggle {
1252
+ border-bottom-left-radius:0;
1253
+ border-top-left-radius:0;
1254
+ }
admin/{css → assets/css}/gmedia.metabox.css RENAMED
File without changes
admin/{img → assets/img}/application.png RENAMED
File without changes
admin/{img → assets/img}/appstore_button.png RENAMED
File without changes
admin/{img → assets/img}/archive.png RENAMED
File without changes
admin/{img → assets/img}/audio.png RENAMED
File without changes
admin/{img → assets/img}/blank.gif RENAMED
File without changes
admin/{img → assets/img}/clicked.png RENAMED
File without changes
admin/{img → assets/img}/code.png RENAMED
File without changes
admin/{img → assets/img}/default.png RENAMED
File without changes
admin/{img → assets/img}/document.png RENAMED
File without changes
admin/{img → assets/img}/gm-icon.png RENAMED
File without changes
admin/{img → assets/img}/grand_icon.png RENAMED
File without changes
admin/{img → assets/img}/icon.png RENAMED
File without changes
admin/{img → assets/img}/icon_edit.png RENAMED
File without changes
admin/{img → assets/img}/interactive.png RENAMED
File without changes
admin/{img → assets/img}/loading.gif RENAMED
File without changes
admin/{img → assets/img}/metabox.png RENAMED
File without changes
admin/{img → assets/img}/mobile_app.png RENAMED
File without changes
admin/{img → assets/img}/refresh.png RENAMED
File without changes
admin/{img → assets/img}/reload.png RENAMED
File without changes
admin/{img → assets/img}/social-footer.png RENAMED
File without changes
admin/{img → assets/img}/spreadsheet.png RENAMED
File without changes
admin/{img → assets/img}/text.png RENAMED
File without changes
admin/{img → assets/img}/throbber.gif RENAMED
File without changes
admin/{img → assets/img}/video.png RENAMED
File without changes
admin/{js → assets/js}/gmedia.admin.js RENAMED
@@ -157,7 +157,113 @@ var GmediaAddMedia = {
157
  }
158
  };
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  var GmediaSelect = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  msg_selected: function(obj, global) {
162
  var gm_cb = jQuery('.' + obj + ' input'),
163
  qty_v = gm_cb.length,
@@ -176,14 +282,13 @@ var GmediaSelect = {
176
  return;
177
  }
178
 
179
- var arr = sel.val().split(','),
180
- cur;
181
 
182
  arr = jQuery.grep(arr, function(e) {
183
  return (e);
184
  });
185
  if(global) {
186
- cur = false;
187
  gm_cb.each(function() {
188
  cur = jQuery(this);
189
  if(cur.is(':checked') && (jQuery.inArray(cur.val(), arr) === -1)) {
@@ -255,6 +360,40 @@ var GmediaSelect = {
255
  jQuery('#gm-selected-btn').submit();
256
  e.preventDefault();
257
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
  cb_global.click(function () {
260
  if (jQuery(this).is(':checked')) {
@@ -304,6 +443,40 @@ var GmediaSelect = {
304
  selected.val(arr);
305
  GmediaSelect.msg_selected(cb_obj);
306
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  jQuery('.term-label').click(function (e) {
308
  if ('DIV' == e.target.nodeName) {
309
  if (!jQuery('#gm-list-table').data('edit')) {
@@ -479,14 +652,34 @@ var GmediaFunction = {
479
  e.preventDefault();
480
  var data = jQuery(this).data(),
481
  modal_div = jQuery(data['target']),
482
- link = jQuery(this).attr('href'),
483
- sharetoemail = jQuery('input.sharetoemail');
 
 
484
 
485
- jQuery('input.sharelink', modal_div).val(link);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  jQuery('.sharebutton').prop('disabled', !validateEmail(sharetoemail.val()));
487
 
488
  modal_div.modal({
489
- backdrop: false,
490
  show: true,
491
  keyboard: false
492
  }).one('shown.bs.modal', function () {
@@ -575,6 +768,9 @@ var GmediaFunction = {
575
 
576
 
577
  jQuery('form.edit-gmedia').on('change', ':input', function () {
 
 
 
578
  jQuery('body').addClass('gmedia-busy');
579
  var post_data = {
580
  action: 'gmedia_update_data', data: jQuery(this).closest('form').serialize(), _wpnonce: jQuery('#_wpnonce').val()
@@ -764,6 +960,7 @@ jQuery(function ($) {
764
  GmediaFunction.init();
765
  GmediaLibrary.init();
766
  GmediaAddMedia.init();
 
767
 
768
  });
769
 
157
  }
158
  };
159
 
160
+ /**
161
+ * Gmedia Terms
162
+ */
163
+ var GmediaTerms = {
164
+ init: function () {
165
+
166
+ jQuery('#gm-list-table').data('edit', false);
167
+ jQuery('input.edit_tag_input').keypress(function(e) {
168
+ var tagdiv = jQuery('#tag_' + jQuery(this).data('tag_id'));
169
+ var charCode = e.charCode || e.keyCode || e.which;
170
+ if(charCode == 13) {
171
+ e.preventDefault();
172
+ edit_tag(tagdiv);
173
+ }
174
+ }).blur(function() {
175
+ var tagdiv = jQuery('#tag_' + jQuery(this).data('tag_id'));
176
+ edit_tag(tagdiv);
177
+ });
178
+
179
+ jQuery('.edit_tag_link').click(function(e) {
180
+ e.preventDefault();
181
+ var id = jQuery(this).attr('href');
182
+ jQuery(this).hide();
183
+ jQuery(id).find('.edit_tag_form').show().find('input').focus();
184
+ jQuery('#gm-list-table').data('edit', true);
185
+ });
186
+ jQuery('.edit_tag_save').click(function(e) {
187
+ e.preventDefault();
188
+ });
189
+
190
+ function edit_tag(tagdiv) {
191
+ var inp = tagdiv.find('.edit_tag_form input');
192
+ var new_tag_name = jQuery.trim(inp.val());
193
+ var old_tag_name = inp.attr('placeholder');
194
+ if((old_tag_name == new_tag_name) || ('' === new_tag_name) || jQuery.isNumeric()) {
195
+ inp.val(old_tag_name);
196
+ tagdiv.find('.edit_tag_form').hide();
197
+ tagdiv.find('.edit_tag_link').show();
198
+ return;
199
+ }
200
+ var post_data = {
201
+ action: 'gmedia_tag_edit',
202
+ tag_id: inp.data('tag_id'),
203
+ tag_name: new_tag_name,
204
+ _wpnonce: jQuery('#_wpnonce').val()
205
+ };
206
+ jQuery.post(ajaxurl, post_data, function(data, textStatus, jqXHR) {
207
+ console.log(data);
208
+ if(data.error) {
209
+ //inp.val(inp.attr('placeholder'));
210
+ jQuery('#gmedia-panel').before(data.error);
211
+ } else {
212
+ //new_tag_name = new_tag_name.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
213
+ inp.attr('placeholder', new_tag_name);
214
+ tagdiv.find('.edit_tag_link').text(new_tag_name).show();
215
+ //noinspection JSUnresolvedVariable
216
+ jQuery('#gmedia-panel').before(data.msg);
217
+ tagdiv.find('.edit_tag_form').hide();
218
+ }
219
+ });
220
+ }
221
+
222
+ }
223
+ };
224
+
225
  var GmediaSelect = {
226
+ msg_stack: function(global) {
227
+ var gm_cb = jQuery('.gm-stack input');
228
+ var sel = jQuery('#gm-stack');
229
+ if(!sel.length) {
230
+ return;
231
+ }
232
+
233
+ var arr = sel.val().split(',');
234
+ arr = jQuery.grep(arr, function(e) {
235
+ return (e);
236
+ });
237
+
238
+ if(global) {
239
+ var cur = false;
240
+ gm_cb.each(function() {
241
+ cur = jQuery(this);
242
+ if(cur.is(':checked') && (jQuery.inArray(cur.val(), arr) === -1)) {
243
+ cur.prop('checked', false);
244
+ } else if(!(cur.is(':checked')) && (jQuery.inArray(cur.val(), arr) !== -1)) {
245
+ cur.prop('checked', true);
246
+ }
247
+ });
248
+ }
249
+
250
+ if(sel.data('userid')) {
251
+ var storedData = getStorage('gmuser_' + sel.data('userid') + '_');
252
+ storedData.set(sel.data('key'), arr);
253
+ }
254
+ jQuery('#gm-stack-qty').text(arr.length);
255
+ if(arr.length) {
256
+ jQuery('#gm-stack-btn').removeClass('hidden');
257
+ jQuery('.rel-stack-show').show();
258
+ jQuery('.rel-stack-hide').hide();
259
+ }
260
+ else {
261
+ jQuery('#gm-stack-btn').addClass('hidden');
262
+ jQuery('.rel-stack-show').hide();
263
+ jQuery('.rel-stack-hide').show();
264
+ }
265
+ sel.trigger('change');
266
+ },
267
  msg_selected: function(obj, global) {
268
  var gm_cb = jQuery('.' + obj + ' input'),
269
  qty_v = gm_cb.length,
282
  return;
283
  }
284
 
285
+ var arr = sel.val().split(',');
 
286
 
287
  arr = jQuery.grep(arr, function(e) {
288
  return (e);
289
  });
290
  if(global) {
291
+ var cur = false;
292
  gm_cb.each(function() {
293
  cur = jQuery(this);
294
  if(cur.is(':checked') && (jQuery.inArray(cur.val(), arr) === -1)) {
360
  jQuery('#gm-selected-btn').submit();
361
  e.preventDefault();
362
  });
363
+ jQuery('#gm-stack-in').click(function (e) {
364
+ e.preventDefault();
365
+ var stack_obj = jQuery('#gm-stack'),
366
+ sel_obj = jQuery('#gm-selected'),
367
+ stack = stack_obj.val().split(','),
368
+ selected = sel_obj.val().split(','),
369
+ arr = stack.concat(selected);
370
+ arr = jQuery.grep(arr, function(e) {
371
+ return (e);
372
+ });
373
+ arr = jQuery.unique(arr);
374
+ stack_obj.val(arr.join(','));
375
+ GmediaSelect.msg_stack(true);
376
+ //sel_obj.val('');
377
+ //GmediaSelect.chk_none(false, cb_obj);
378
+ //GmediaSelect.msg_selected(cb_obj);
379
+ });
380
+ jQuery('#gm-stack-out').click(function (e) {
381
+ e.preventDefault();
382
+ var stack_obj = jQuery('#gm-stack'),
383
+ sel_obj = jQuery('#gm-selected'),
384
+ stack = stack_obj.val().split(','),
385
+ selected = sel_obj.val().split(','),
386
+ arr = jQuery(stack).not(selected).get();
387
+ arr = jQuery.grep(arr, function(e) {
388
+ return (e);
389
+ });
390
+ arr = jQuery.unique(arr);
391
+ stack_obj.val(arr.join(','));
392
+ GmediaSelect.msg_stack(true);
393
+ //sel_obj.val('');
394
+ //GmediaSelect.chk_none(false, cb_obj);
395
+ //GmediaSelect.msg_selected(cb_obj);
396
+ });
397
  }
398
  cb_global.click(function () {
399
  if (jQuery(this).is(':checked')) {
443
  selected.val(arr);
444
  GmediaSelect.msg_selected(cb_obj);
445
  });
446
+
447
+ if (jQuery('#gm-stack').length) {
448
+ GmediaSelect.msg_stack();
449
+ jQuery('#gm-stack-clear').click(function (e) {
450
+ jQuery('#gm-stack').val('');
451
+ jQuery('.gm-stack input').prop('checked', false);
452
+ GmediaSelect.msg_stack();
453
+ e.preventDefault();
454
+ });
455
+ jQuery('#gm-stack-show').click(function (e) {
456
+ jQuery('#gm-stack-btn').submit();
457
+ e.preventDefault();
458
+ });
459
+
460
+ }
461
+ jQuery('.gm-stack input:checkbox').change(function () {
462
+ var selected = jQuery('#gm-stack'),
463
+ arr = selected.val();
464
+ var cur = jQuery(this).val();
465
+ if (jQuery(this).is(':checked')) {
466
+ if (arr) {
467
+ arr = arr + ',' + cur;
468
+ } else {
469
+ arr = cur;
470
+ }
471
+ } else {
472
+ arr = jQuery.grep(arr.split(','), function (a) {
473
+ return a != cur;
474
+ }).join(',');
475
+ }
476
+ selected.val(arr);
477
+ GmediaSelect.msg_stack();
478
+ });
479
+
480
  jQuery('.term-label').click(function (e) {
481
  if ('DIV' == e.target.nodeName) {
482
  if (!jQuery('#gm-list-table').data('edit')) {
652
  e.preventDefault();
653
  var data = jQuery(this).data(),
654
  modal_div = jQuery(data['target']),
655
+ postlink = jQuery(this).attr('href'),
656
+ cloudlink = jQuery(this).attr('data-gmediacloud'),
657
+ sharetoemail = jQuery('input.sharetoemail'),
658
+ cloudlink_checked = false;
659
 
660
+ if(postlink) {
661
+ jQuery('.sharelink_post', modal_div).show();
662
+ jQuery('.sharelink_post input', modal_div).val(postlink);
663
+ jQuery('.sharelink_post a', modal_div).attr('href', postlink);
664
+ } else {
665
+ jQuery('.sharelink_post', modal_div).hide();
666
+ jQuery('.sharelink_post input[type="radio"]', modal_div).prop('checked', false);
667
+ cloudlink_checked = true;
668
+ }
669
+ if(cloudlink) {
670
+ jQuery('.sharelink_page', modal_div).show();
671
+ jQuery('.sharelink_page input', modal_div).val(cloudlink);
672
+ jQuery('.sharelink_page a', modal_div).attr('href', cloudlink);
673
+ if(cloudlink_checked){
674
+ jQuery('.sharelink_page input[type="radio"]', modal_div).prop('checked', true);
675
+ }
676
+ } else {
677
+ jQuery('.sharelink_page', modal_div).hide();
678
+ }
679
  jQuery('.sharebutton').prop('disabled', !validateEmail(sharetoemail.val()));
680
 
681
  modal_div.modal({
682
+ backdrop: true,
683
  show: true,
684
  keyboard: false
685
  }).one('shown.bs.modal', function () {
768
 
769
 
770
  jQuery('form.edit-gmedia').on('change', ':input', function () {
771
+ if(jQuery(this).hasClass('edit-gmedia-ignore')){
772
+ return;
773
+ }
774
  jQuery('body').addClass('gmedia-busy');
775
  var post_data = {
776
  action: 'gmedia_update_data', data: jQuery(this).closest('form').serialize(), _wpnonce: jQuery('#_wpnonce').val()
960
  GmediaFunction.init();
961
  GmediaLibrary.init();
962
  GmediaAddMedia.init();
963
+ GmediaTerms.init();
964
 
965
  });
966
 
admin/{js → assets/js}/gmedia.global.js RENAMED
@@ -1,8 +1,8 @@
1
  /**
2
  * Gmedia Globals
3
- * @var gmediaGlobalVar
4
  */
5
  if (!ajaxurl) {
6
  //noinspection JSUnresolvedVariable
7
- var ajaxurl = gmediaGlobalVar.ajaxurl;
8
  }
1
  /**
2
  * Gmedia Globals
3
+ * @var GmediaGallery
4
  */
5
  if (!ajaxurl) {
6
  //noinspection JSUnresolvedVariable
7
+ var ajaxurl = GmediaGallery.ajaxurl;
8
  }
admin/{js → assets/js}/gmedia.metabox.js RENAMED
@@ -91,7 +91,7 @@ var gmActiveEditor = false;
91
  $(document).on('click', '#gmedia-modal', function (e) {
92
  e.stopPropagation();
93
  e.preventDefault();
94
- gmedia_post_modal();
95
  });
96
 
97
  $('#postimagediv').on('click', '#set-gmedia-post-thumbnail', function (e) {
@@ -110,13 +110,13 @@ var gmActiveEditor = false;
110
 
111
  })(jQuery, window, document, undefined);
112
 
113
- function gmedia_post_modal() {
114
  var modal = jQuery('#__gm-uploader');
115
 
116
  if (modal.length) {
117
  modal.css('display', 'block');
118
  } else {
119
- var title = jQuery(this).attr('title');
120
  modal = jQuery(jQuery('#tpl__gm-uploader').html());
121
  modal.find('.media-modal-close, .media-modal-backdrop').on('click', function () {
122
  modal.css('display', 'none');
91
  $(document).on('click', '#gmedia-modal', function (e) {
92
  e.stopPropagation();
93
  e.preventDefault();
94
+ gmedia_post_modal(this);
95
  });
96
 
97
  $('#postimagediv').on('click', '#set-gmedia-post-thumbnail', function (e) {
110
 
111
  })(jQuery, window, document, undefined);
112
 
113
+ function gmedia_post_modal(el) {
114
  var modal = jQuery('#__gm-uploader');
115
 
116
  if (modal.length) {
117
  modal.css('display', 'block');
118
  } else {
119
+ //var title = jQuery(el).attr('title');
120
  modal = jQuery(jQuery('#tpl__gm-uploader').html());
121
  modal.find('.media-modal-close, .media-modal-backdrop').on('click', function () {
122
  modal.css('display', 'none');
admin/class.processor.php CHANGED
@@ -5,6 +5,7 @@
5
  class GmediaProcessor {
6
 
7
  public $page;
 
8
  public $msg;
9
  public $error;
10
  public $user_options = array();
@@ -16,9 +17,13 @@ class GmediaProcessor {
16
  global $pagenow, $gmCore;
17
  // GET variables
18
  $this->page = $gmCore->_get('page');
 
19
  if('media.php' === $pagenow) {
20
  add_filter('wp_redirect', array($this, 'redirect'), 10, 2);
21
  }
 
 
 
22
 
23
  add_action('init', array($this, 'controller'));
24
 
@@ -37,7 +42,6 @@ class GmediaProcessor {
37
 
38
  auth_redirect();
39
 
40
-
41
  $this->processor();
42
  }
43
 
@@ -61,16 +65,18 @@ class GmediaProcessor {
61
  }
62
 
63
  /**
64
- * @param $cookie_key
 
 
65
  *
66
  * @return array
67
  */
68
- public static function selected_items($cookie_key) {
69
 
70
  $selected_items = array();
71
  if($cookie_key) {
72
- if(isset($_POST['selected_items'])) {
73
- $selected_items = array_filter(explode(',', $_POST['selected_items']), 'is_numeric');
74
  } elseif(isset($_COOKIE[$cookie_key])) {
75
  $selected_items = array_filter(explode(',', $_COOKIE[$cookie_key]), 'is_numeric');
76
  }
@@ -79,6 +85,21 @@ class GmediaProcessor {
79
  return $selected_items;
80
  }
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  /**
83
  * @param bool|string|array $author_id_list
84
  *
@@ -91,31 +112,15 @@ class GmediaProcessor {
91
  if($gmCore->caps['gmedia_show_others_media']) {
92
  if(!empty($author_id_list)) {
93
  $author = wp_parse_id_list($author_id_list);
 
94
  }
95
  } else {
96
- $author = array($user_ID);
97
  }
98
 
99
  return $author;
100
  }
101
 
102
- /**
103
- * @param string $type
104
- * @param string $content
105
- *
106
- * @return string
107
- */
108
- public function alert($type = 'info', $content = '') {
109
- if(empty($content)) {
110
- return '';
111
- } elseif(is_array($content)) {
112
- $content = implode('<br />', array_filter($content));
113
- }
114
- $alert = '<div class="alert alert-' . $type . ' alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' . $content . '</div>';
115
-
116
- return $alert;
117
- }
118
-
119
  /**
120
  * redirect to original referer after update
121
  *
@@ -137,11 +142,35 @@ class GmediaProcessor {
137
  return $location;
138
  }
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  /**
141
  * Autoloader
142
  */
143
  public static function autoload() {
144
- $path_ = GMEDIA_ABSPATH . '/admin/class.processor.';
145
  $page = isset($_GET['page'])? $_GET['page'] : '';
146
  switch($page) {
147
  case 'GrandMedia':
5
  class GmediaProcessor {
6
 
7
  public $page;
8
+ public $url;
9
  public $msg;
10
  public $error;
11
  public $user_options = array();
17
  global $pagenow, $gmCore;
18
  // GET variables
19
  $this->page = $gmCore->_get('page');
20
+ $this->url = add_query_arg(array('page' => $this->page), admin_url('admin.php'));
21
  if('media.php' === $pagenow) {
22
  add_filter('wp_redirect', array($this, 'redirect'), 10, 2);
23
  }
24
+ if('edit-comments.php' === $pagenow) {
25
+ add_filter('get_comment_text', array($this, 'gmedia_comment_text'), 10, 3);
26
+ }
27
 
28
  add_action('init', array($this, 'controller'));
29
 
42
 
43
  auth_redirect();
44
 
 
45
  $this->processor();
46
  }
47
 
65
  }
66
 
67
  /**
68
+ * @param string $cookie_key
69
+ *
70
+ * @param string $post_key
71
  *
72
  * @return array
73
  */
74
+ public static function selected_items($cookie_key, $post_key = 'selected_items') {
75
 
76
  $selected_items = array();
77
  if($cookie_key) {
78
+ if(isset($_POST[$post_key])) {
79
+ $selected_items = array_filter(explode(',', $_POST[$post_key]), 'is_numeric');
80
  } elseif(isset($_COOKIE[$cookie_key])) {
81
  $selected_items = array_filter(explode(',', $_COOKIE[$cookie_key]), 'is_numeric');
82
  }
85
  return $selected_items;
86
  }
87
 
88
+ /**
89
+ * @param string $cookie_key
90
+ *
91
+ * @return array
92
+ */
93
+ public function clear_selected_items($cookie_key) {
94
+ global $user_ID;
95
+
96
+ if($cookie_key) {
97
+ setcookie("gmuser_{$user_ID}_{$cookie_key}", '', time() - 3600);
98
+ unset($_COOKIE["gmuser_{$user_ID}_{$cookie_key}"]);
99
+ }
100
+ return array();
101
+ }
102
+
103
  /**
104
  * @param bool|string|array $author_id_list
105
  *
112
  if($gmCore->caps['gmedia_show_others_media']) {
113
  if(!empty($author_id_list)) {
114
  $author = wp_parse_id_list($author_id_list);
115
+ $author = array_intersect(array($user_ID, 0), $author);
116
  }
117
  } else {
118
+ $author = array($user_ID, 0);
119
  }
120
 
121
  return $author;
122
  }
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  /**
125
  * redirect to original referer after update
126
  *
142
  return $location;
143
  }
144
 
145
+ /**
146
+ * Add thumb to gmedia comment text in admin
147
+ *
148
+ * @param $comment_content
149
+ * @param $comment
150
+ * @param $args
151
+ *
152
+ * @return string $comment_content
153
+ */
154
+ function gmedia_comment_text($comment_content, $comment, $args) {
155
+ global $post;
156
+ if(!$post){
157
+ return $comment_content;
158
+ }
159
+ //if('gmedia' == substr($post->post_type, 0, 6)) {
160
+ if('gmedia' == $post->post_type) {
161
+ global $gmDB, $gmCore;
162
+ $gmedia = $gmDB->get_post_gmedia($post->ID);
163
+ $thumb = '<div class="alignright"><img class="gmedia-thumb" style="max-height:72px;" src="' . $gmCore->gm_get_media_image($gmedia, 'thumb', false) . '" alt=""/></div>';
164
+ $comment_content = $thumb . $comment_content;
165
+ }
166
+ return $comment_content;
167
+ }
168
+
169
  /**
170
  * Autoloader
171
  */
172
  public static function autoload() {
173
+ $path_ = GMEDIA_ABSPATH . '/admin/processor/class.processor.';
174
  $page = isset($_GET['page'])? $_GET['page'] : '';
175
  switch($page) {
176
  case 'GrandMedia':
admin/css/gmedia.admin.css DELETED
@@ -1,1246 +0,0 @@
1
- html {
2
- background:#708090;
3
- }
4
- #adminmenu #toplevel_page_GrandMedia ul.wp-submenu {
5
- display:none;
6
- }
7
- #wpfooter {
8
- color:#ffffff;
9
- }
10
- #wpfooter a {
11
- color:lightblue;
12
- }
13
- #TB_caption {
14
- height:auto;
15
- }
16
- a {
17
- color:#0074a2;
18
- }
19
- input[type="checkbox"] {
20
- margin-top:2px;
21
- margin-right:2px
22
- }
23
- input[type="checkbox"], input[type="radio"] {
24
- height:16px;
25
- width:16px;
26
- }
27
- input::-moz-focus-inner {
28
- border:0;
29
- padding:0;
30
- margin-top:-2px;
31
- margin-bottom:-2px;
32
- }
33
- form, .row form {
34
- margin:0;
35
- }
36
- legend.label { text-align:left; }
37
- textarea.vert { resize:vertical; }
38
- textarea.noResize { resize:none; }
39
- body.gmedia-busy {
40
- cursor:wait !important;
41
- }
42
- iframe, iframe html {
43
- background-color:#ffffff;
44
- }
45
- body.gmedia-blank {
46
- background-color:#ffffff;
47
- height:auto;
48
- min-height:100%;
49
- padding:0 0 1px;
50
- box-sizing:border-box;
51
- }
52
- body.gmedia-blank pre {
53
- margin:0;
54
- padding:0;
55
- border:none;
56
- }
57
- .gmedia-body div#gm-message {
58
- position:absolute;
59
- right:5px;
60
- top:5px;
61
- overflow:visible;
62
- z-index:200;
63
- }
64
- .gmedia-body div#gm-message .gm-message {
65
- text-align:right;
66
- }
67
- div#gmedia-container {
68
- font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
69
- margin:30px 5px 10px 0;
70
- position:relative;
71
- z-index:1;
72
- direction:ltr;
73
- min-width:560px;
74
- }
75
- div#gmedia-header {
76
- position:relative;
77
- padding:1px 1px 10px 1px;
78
- }
79
- /*noinspection CssInvalidElement*/
80
- div#gmedia-logo {
81
- position:relative;
82
- margin:0 30px 0 15px;
83
- font-size:48px;
84
- text-shadow:1px 1px 4px #000000;
85
- font-family:Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
86
- color:#ffffff;
87
- float:left;
88
- /*noinspection CssFloatPxLength*/
89
- -webkit-text-stroke-width:0.7px;
90
- -webkit-text-stroke-color:#ffffff;
91
- -webkit-font-smoothing:antialiased;
92
- -webkit-user-select:none;
93
- -moz-user-select:none;
94
- -ms-user-select:none;
95
- user-select:none;
96
- cursor:default;
97
- }
98
- div#gmedia-logo small {
99
- display:block;
100
- font-size:10px;
101
- margin-top:7px;
102
- text-align:right;
103
- -webkit-text-stroke-width:0;
104
- }
105
- div#gmedia-header h2 {
106
- margin:0;
107
- font:italic 24px/35px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
108
- color:#ffffff;
109
- }
110
- div#gmedia-navbar {
111
- font-size:14px;
112
- }
113
- div.custom-message {
114
- padding:5px 10px;
115
- margin:0 0 10px;
116
- }
117
- form.gmedia-search-form {
118
- float:right;
119
- margin-left:10px;
120
- margin-bottom:4px;
121
- white-space:nowrap;
122
- }
123
- form.gmedia-search-form .form-group {
124
- margin:0;
125
- display:inline-block;
126
- vertical-align:middle;
127
- }
128
- .gmedia-pager {
129
- margin-bottom:4px;
130
- }
131
- form#gmedia-pager {
132
- float:left;
133
- width:auto;
134
- display:block;
135
- }
136
- form#gmedia-pager span,
137
- form#gmedia-pager input {
138
- width:auto;
139
- display:inline-block;
140
- vertical-align:inherit;
141
- float:none;
142
- }
143
- form#gmedia-pager input.pager_current_page {
144
- padding-left:0;
145
- padding-right:0;
146
- text-align:center;
147
- width:2.5em;
148
- }
149
- .txt-lg {
150
- font-size:120%;
151
- line-height:50%;
152
- }
153
- a.text-danger {
154
- color:#a94442;
155
- }
156
- .btn > input[type="checkbox"] {
157
- margin-top:0;
158
- width:16px;
159
- height:16px;
160
- }
161
- .va-middle { vertical-align:middle }
162
- .dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
163
- background-color:#e8e8e8;
164
- }
165
- .gm-checkgroup {
166
- margin-right:20px;
167
- }
168
- .gm-backfade {
169
- background-color:rgba(0, 0, 0, 0.1);
170
- }
171
- .dropdown-menu > .disabled {
172
- cursor:not-allowed;
173
- }
174
- .dropdown-menu > .disabled > a {
175
- pointer-events:none;
176
- }
177
- .panel-heading-fake { display:none; }
178
- .panel-floatingHeader .panel-heading-fake,
179
- .panel-absoluteHeader .panel-heading-fake { display:block; }
180
- .panel-fixed-header { position:relative; }
181
- .panel-fixed-header .panel-heading { position:relative; top:0; max-width:100%;
182
- /*transition:top 0.2s ease-out; -webkit-transition:top 0.2s ease-out;*/
183
- }
184
- .panel-floatingHeader .panel-heading {
185
- position:fixed;
186
- top:32px;
187
- z-index:20;
188
- border-radius:0;
189
- -webkit-box-shadow:0 5px 10px #888888;
190
- -moz-box-shadow:0 5px 10px #888888;
191
- box-shadow:0 5px 10px #888888;
192
- }
193
- .panel-absoluteHeader .panel-heading {
194
- position:absolute;
195
- z-index:10;
196
- top:auto;
197
- bottom:0;
198
- border-bottom:1px solid transparent;
199
- border-bottom-right-radius:3px;
200
- border-bottom-left-radius:3px;
201
- }
202
- div#gm-list-table {
203
- font-size:13px;
204
- }
205
- .list-group-item.row {
206
- position:relative;
207
- margin-left:0;
208
- margin-right:0;
209
- padding-left:0;
210
- padding-right:0;
211
- }
212
- .list-group-item.d-row {
213
- position:relative;
214
- color:inherit;
215
- z-index:1;
216
- }
217
- .no-touch div.list-group-item.d-row:hover {
218
- background-color:#fafafa;
219
- }
220
- .no-touch form.list-group-item.d-row:hover {
221
- background-color:#fcfcfc;
222
- }
223
- .list-group-item.d-row.gm-selected {
224
- color:#444;
225
- border-color:#ddd;
226
- background-color:rgb(250, 255, 245);
227
- -webkit-box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
228
- -moz-box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
229
- box-shadow:inset -1px 0 0 2px rgb(250, 255, 245), inset 7px 0 0 0 #1e8cbe;
230
- }
231
- .no-touch .list-group-item.d-row.gm-selected:hover {
232
- color:#444;
233
- border-color:#ddd;
234
- background-color:rgb(245, 255, 240);
235
- -webkit-box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
236
- -moz-box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
237
- box-shadow:inset -1px 0 0 2px rgb(245, 255, 240), inset 7px 0 0 0 #1e8cbe;
238
- }
239
- div#gmedia-container .list-group-item-info,
240
- div#gmedia-container .list-group-item-info:hover {
241
- background-color:#d9edf7 !important;
242
- }
243
- div#gmedia-container .list-group-item-warning,
244
- div#gmedia-container .list-group-item-warning:hover {
245
- background-color:#fcf8e3 !important;
246
- }
247
- div#gmedia-container .item-after-limit {
248
- filter:blur(1px);
249
- -webkit-filter:blur(1px);
250
- -moz-filter:blur(1px);
251
- -o-filter:blur(1px);
252
- -ms-filter:blur(1px);
253
- filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius='1');
254
- }
255
- .gm-img-thumbnail:not(.item-after-limit) + .item-after-limit {
256
- clear:left;
257
- }
258
- .bg-status-private {
259
- background-color:#d9edf7;
260
- -webkit-box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
261
- -moz-box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
262
- box-shadow:3px 0 0 5px #d9edf7, -2px 0 0 5px #6fbfff;
263
- }
264
- .bg-status-draft {
265
- background-color:#fcf8e3;
266
- -webkit-box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
267
- -moz-box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
268
- box-shadow:3px 0 0 5px #fcf8e3, -2px 0 0 5px #ffd87c;
269
- }
270
- label.cb_media-object-gallery {
271
- width:40px;
272
- position:absolute;
273
- left:5px;
274
- top:0; bottom:0;
275
- text-align:center;
276
- }
277
- .d-row .thumbnail {
278
- margin-bottom:0;
279
- }
280
- .gm-selected .thumbnail {
281
- border-color:#428bca;
282
- }
283
- .thumbnail {
284
- position:relative;
285
- display:inline-block;
286
- max-width:100%;
287
- }
288
-
289
- .display-as-grid .gm-item-cell {
290
- padding:15px;
291
- }
292
- .display-as-grid div.thumbnail {
293
- cursor:pointer;
294
- position:relative;
295
- display:block;
296
- border-radius:0;
297
- margin:0;
298
- padding:0;
299
- }
300
- .display-as-grid div.thumbnail:before {
301
- content:"";
302
- display:block;
303
- padding-top:100%;
304
- }
305
- .display-as-grid .gm-selected div.thumbnail {
306
- -webkit-box-shadow: 0 0 0 7px #1e8cbe;
307
- -moz-box-shadow: 0 0 0 7px #1e8cbe;
308
- box-shadow: 0 0 0 7px #1e8cbe;
309
- }
310
- .display-as-grid div.thumbnail .cb_media-object {
311
- bottom: 0px;
312
- left: 0px;
313
- overflow: hidden;
314
- position: absolute;
315
- right: 0px;
316
- top: 0px;
317
- text-align:center;
318
- margin:0;
319
- }
320
- .display-as-grid div.thumbnail .gm-cell-more {
321
- position:absolute;
322
- left:0; top:0; right:0;
323
- background:rgba(256, 256, 256, 0.6);
324
- color:#000000;
325
- cursor:auto;
326
- }
327
- .display-as-grid div.thumbnail .gm-cell-title {
328
- overflow:hidden;
329
- font-size:12px;
330
- font-weight:bold;
331
- padding:5px 25px 4px 7px;
332
- cursor:pointer;
333
- }
334
- .display-as-grid div.thumbnail .gm-cell-title span {
335
- display:block;
336
- width:100%;
337
- white-space:nowrap;
338
- text-overflow:ellipsis;
339
- overflow:hidden;
340
- }
341
- .display-as-grid div.thumbnail .gm-cell-more-btn {
342
- position:absolute;
343
- top:7px; right:2px;
344
- padding:0 5px;
345
- cursor:pointer;
346
- }
347
- .display-as-grid div.thumbnail .gm-cell-more-content {
348
- padding:0 5px;
349
- height:0;
350
- overflow:hidden;
351
- transition:all 0.2s easy-out;
352
- font-size:11px;
353
- }
354
- .display-as-grid div.thumbnail .gm-cell-more-content .gmedia-actions {
355
- display:none;
356
- }
357
- .display-as-grid div.thumbnail .gm-cell-more:hover,
358
- .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active {
359
- z-index:10;
360
- -webkit-box-shadow: 0 0 0 1px #ddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
361
- -moz-box-shadow: 0 0 0 1px #ddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
362
- box-shadow: 0 0 0 1px #ddd, 0 4px 3px -1px rgba(0, 0, 0, 0.3);
363
- }
364
- .display-as-grid div.thumbnail .gm-cell-more:hover {
365
- z-index:11;
366
- }
367
- .display-as-grid div.thumbnail .gm-cell-more:hover > div {
368
- background:rgba(256, 256, 256, 0.7);
369
- }
370
- .display-as-grid div.thumbnail .gm-cell-more-active .gm-cell-more-content .gmedia-actions {
371
- display:block;
372
- }
373
- .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active > div {
374
- background:rgba(256, 256, 256, 0.9);
375
- }
376
- .display-as-grid div.thumbnail .gm-cell-more:hover .gm-cell-more-content,
377
- .display-as-grid div.thumbnail .gm-cell-more.gm-cell-more-active .gm-cell-more-content {
378
- height:auto;
379
- }
380
- .display-as-grid div.thumbnail .gm-cell-more-content p {
381
- font-size:11px;
382
- }
383
- .display-as-grid div.thumbnail .cb_media-object .centered {
384
- height: 100%;
385
- left: 0;
386
- position: absolute;
387
- top: 0;
388
- transform: translate(50%, 50%);
389
- width: 100%;
390
- }
391
- .display-as-grid div.thumbnail.landscape .cb_media-object .centered {
392
- transform: translate(50%, 50.5%);
393
- }
394
- .display-as-grid div.thumbnail .cb_media-object img {
395
- left: 0;
396
- position: absolute;
397
- top: 0;
398
- transform: translate(-50%, -50%);
399
- }
400
- .display-as-grid div.thumbnail.landscape img {
401
- height:101%;
402
- width:auto;
403
- }
404
- .display-as-grid div.thumbnail.portrait img {
405
- height:auto;
406
- width:100%;
407
- }
408
- .display-as-grid.invert-ratio div.thumbnail.landscape img {
409
- height:auto;
410
- width:101%;
411
- }
412
- .display-as-grid.invert-ratio div.thumbnail.portrait img {
413
- height:101%;
414
- width:auto;
415
- }
416
-
417
- .thumbnail .gmedia-typethumb {
418
- position:absolute;
419
- right:5px;
420
- bottom:7px;
421
- height:75px;
422
- max-height:60%;
423
- width:auto;
424
- }
425
- .media-title {
426
- font-weight:bold;
427
- font-size:15px;
428
- }
429
- .media-caption:empty { display:none; }
430
- .media-caption.in-library {
431
- max-height:215px;
432
- }
433
- .media-caption {
434
- background-color:#f5f5f5;
435
- border:1px solid #ccc;
436
- border-radius:4px;
437
- padding:5px 7px;
438
- margin:0 -6px 5px;
439
- overflow:auto;
440
- word-break:normal;
441
- word-wrap:break-word;
442
- max-height:210px;
443
- }
444
- .media-body .media-caption {
445
- margin:0;
446
- }
447
- .media-meta {
448
- width:100%;
449
- overflow:hidden;
450
- text-overflow:ellipsis; /*white-space:nowrap;*/
451
- }
452
- .media-meta .gm_gallery_source { font-weight:bold; }
453
- .media-meta .label-default {
454
- background-color:#eeeeee;
455
- color:#444444;
456
- }
457
- .gmedia_id {
458
- position:absolute;
459
- right:10px;
460
- top:10px;
461
- }
462
- .no-touch .gmedia_id,
463
- .no-touch .term_id {
464
- display:none;
465
- }
466
- .term_id {
467
- position:absolute;
468
- right:0;
469
- top:0;
470
- padding:10px 10px 0 0;
471
- background-color:#fff;
472
- display:none;
473
- height:100%;
474
- -webkit-box-shadow:-10px 0 5px -2px #fff;
475
- -moz-box-shadow:-10px 0 5px -2px #fff;
476
- box-shadow:-10px 0 5px -2px #fff;
477
- z-index:1000;
478
- }
479
- .term-list-item.gm-selected .term_id {
480
- display:block;
481
- }
482
- .no-touch #gm-list-table .list-group-item:hover .gmedia_id,
483
- .no-touch #gm-list-table .list-group-item:hover .term_id {
484
- display:block;
485
- }
486
- #gm-list-table .hidden {
487
- display:none !important;
488
- visibility:hidden !important;
489
- }
490
- form#adv-settings .form-inline .form-group {
491
- margin-right:20px;
492
- }
493
- form.changed {
494
- }
495
- form.changed.saved {
496
- }
497
- form.changed .gm-last-edited {
498
- text-decoration:line-through;
499
- }
500
- .selectize-input.full input {
501
- width:4px !important;
502
- }
503
- .rel-selected-hide {
504
- display:none;
505
- }
506
- .plupload_wrapper {
507
- min-width:unset;
508
- }
509
- div#pluploadUploader {
510
- padding:0;
511
- }
512
- div#pluploadUploader * {
513
- box-sizing:border-box;
514
- }
515
- div#pluploadUploader > div > div * {
516
- box-sizing:content-box;
517
- }
518
- .plupload_container {
519
- padding:0;
520
- }
521
- div#pluploadUploader_container {
522
- min-height:450px;
523
- border-bottom-right-radius:4px;
524
- }
525
- div#pluploadUploader_container .plupload_filelist_footer {
526
- border-bottom-right-radius:4px;
527
- font-size:11px;
528
- white-space:nowrap;
529
- }
530
- div#pluploadUploader_buttons { margin-bottom:5px; }
531
- div.plupload_started { float:left; }
532
- div.panel-body, div#gmedia-msg-panel {
533
- -webkit-transition:all .2s ease-in-out;
534
- transition:all .2s ease-in-out;
535
- }
536
- div.panel-body:empty, div#gmedia-msg-panel:empty {
537
- padding:0;
538
- }
539
- div#gmedia-msg-panel .alert {
540
- padding:2px 35px 2px 12px;
541
- margin-bottom:5px;
542
- }
543
- .plupload_content li {
544
- margin-bottom:0;
545
- }
546
- .progress {
547
- position:relative;
548
- white-space:nowrap;
549
- font-size:12px;
550
- line-height:20px;
551
- }
552
- .progress-bar {
553
- position:absolute;
554
- overflow:hidden;
555
- }
556
- .tab-inside {
557
- padding:10px;
558
- position:relative;
559
- }
560
- .tab-footer {
561
- border-top:1px solid #ddd;
562
- padding:20px 10px 0;
563
- }
564
- .selectize-control.input-sm .selectize-input {
565
- min-height:30px;
566
- padding:2px 10px;
567
- font-size:12px;
568
- line-height:1.9;
569
- border-radius:3px;
570
- }
571
- .selectize-control.multi .selectize-input.has-items {
572
- padding-top:2px;
573
- }
574
- .selectize-control.input-sm .selectize-input input {
575
- font-size:12px;
576
- }
577
- .selectize-control.input-sm .selectize-input:after {
578
- right:10px;
579
- }
580
- .selectize-control.input-sm .selectize-input > div {
581
- line-height:146%;
582
- }
583
- .term-list-item {
584
- padding-top:0;
585
- padding-bottom:0;
586
- z-index:1;
587
- }
588
- #gmedia-container .cb_term-object { min-height:60px; }
589
- #gmedia-container .gmedia_album .cb_term-object { min-height:78px; }
590
- .object-actions { text-align:right; font-size:16px; }
591
- .object-actions.gallery-object-actions { text-align:left; margin-bottom:5px; }
592
- .object-actions > * { margin:0 0 0 10px; vertical-align:middle; display:inline-block; }
593
- .object-actions a:hover { text-decoration:none; }
594
- .gm_filter_in_lib { border:1px solid; border-radius:4px; font-size:14px; line-height:14px; padding:0 2px 0 4px; }
595
- .gm_term_count { font-size:13px; font-weight:bold; text-decoration:none; vertical-align:bottom; }
596
- a.trash-icon:hover { color:#843534; }
597
- .action-inactive { color:#b8b8b8; }
598
- .action-inactive:hover { color:#b8b8b8; }
599
- .term-list-item .term-label .checkbox {
600
- padding-left:35px;
601
- }
602
- .term-list-item .term-label .checkbox > input {
603
- margin-left:-35px;
604
- }
605
- .term-list-item .checkbox input {
606
- margin-top:0;
607
- margin-right:15px;
608
- }
609
- .term-list-item .term-description {
610
- padding:0;
611
- white-space:nowrap;
612
- overflow:hidden;
613
- color:#444444;
614
- text-overflow:ellipsis;
615
- }
616
- .term-list-item .term-description:empty {
617
- padding:0;
618
- }
619
- .term-list-item .term-images {
620
- padding-top:5px;
621
- padding-bottom:5px;
622
- overflow:hidden;
623
- white-space:nowrap;
624
- position:relative;
625
- z-index:1;
626
- }
627
- .term-list-item .term-images img {
628
- position:relative;
629
- height:50px;
630
- width:auto;
631
- background-color:#ffffff;
632
- }
633
- .term-list-item .term_name {
634
- margin-right:10px;
635
- }
636
- .gmedia_album .term-list-item .term-images img { height:68px; }
637
- .gmedia_album .term-list-item .term_name { font-size:14px; font-weight:bold; }
638
- .term-list-item .term_info_author {
639
- font-size:80%;
640
- white-space:nowrap;
641
- color:#444;
642
- }
643
- .no-touch .term-list-item .term-images img:hover {
644
- z-index:100 !important;
645
- }
646
- .edit_tag_form {
647
- display:inline-block;
648
- margin-left:-5px;
649
- margin-bottom:-1px;
650
- margin-top:-1px;
651
- }
652
- .edit_tag_form input.edit_tag_input {
653
- padding:0 5px;
654
- border-width:0 0 1px 0;
655
- margin:0;
656
- }
657
- a.edit_tag_save.btn {
658
- padding-top:0;
659
- padding-bottom:0;
660
- }
661
- .no-touch a.edit_tag_save.btn-link:hover {
662
- text-decoration:none;
663
- }
664
- .gm-img-thumbnail {
665
- display:inline-block;
666
- float:left;
667
- position:relative;
668
- margin-right:5px;
669
- margin-bottom:25px;
670
- max-width:100%;
671
- height:auto;
672
- padding:4px;
673
- line-height:1.428571429;
674
- background-color:#fff;
675
- border:1px solid #ddd;
676
- border-radius:4px;
677
- }
678
- .gm-img-thumbnail input {
679
- display:block;
680
- line-height:120%;
681
- position:absolute;
682
- right:-1px;
683
- top:-1px;
684
- width:42px;
685
- padding:0 2px;
686
- text-align:center;
687
- border-radius:4px;
688
- opacity:0.9;
689
- }
690
- .gm-img-thumbnail input:focus {
691
- opacity:1;
692
- }
693
- .gm-img-thumbnail .label {
694
- position:absolute;
695
- left:0;
696
- bottom:0;
697
- font-weight:normal;
698
- line-height:120%;
699
- pointer-events:none;
700
- }
701
- .gm-img-thumbnail .gm-img-thumb-title {
702
- position:absolute;
703
- left:0;
704
- top:100%;
705
- font-size:90%;
706
- line-height:120%;
707
- width:100%;
708
- padding:3px;
709
- text-overflow:ellipsis;
710
- white-space:nowrap;
711
- overflow:hidden;
712
- text-align:left;
713
- }
714
- .gm-img-thumbnail.ui-sortable-helper .gm-img-thumb-title {
715
- visibility:hidden;
716
- }
717
- .ui-highlight-placeholder {
718
- border:1px solid #0074a2;
719
- }
720
- .termItems {
721
- position:relative;
722
- }
723
- .termItems .gm-img-thumbnail {
724
- width:160px;
725
- height:120px;
726
- text-align:center;
727
- line-height:107px;
728
- }
729
- #gmedia-edit-term .gm-img-thumbnail {
730
- height:121px;
731
- text-align:center;
732
- margin:0;
733
- line-height:107px;
734
- }
735
- .gm-img-thumbnail img {
736
- height:auto;
737
- width:auto;
738
- max-width:100%;
739
- max-height:100%;
740
- display:inline-block;
741
- vertical-align:middle;
742
- }
743
- .choose-module {
744
- padding:10px;
745
- cursor:pointer;
746
- overflow:hidden;
747
- margin:0;
748
- }
749
- .no-touch .choose-module:hover {
750
- background-color:#d0e9c6;
751
- }
752
- .choose-module .thumbnail {
753
- margin-bottom:0;
754
- }
755
- .media {
756
- overflow:hidden;
757
- }
758
- .media > .thumbnail.pull-left {
759
- padding:4px;
760
- margin-right:10px
761
- }
762
- .presetlist a {
763
- position:relative;
764
- padding-right:30px;
765
- }
766
- .delpreset {
767
- position:absolute;
768
- right:0;
769
- top:0;
770
- bottom:0;
771
- padding:0.8em 7px 0;
772
- line-height:100%;
773
- }
774
- .delpreset span {
775
- line-height:100%;
776
- font-size:94%;
777
- padding:0 5px 2px;
778
- cursor:pointer;
779
- }
780
- body#media-upload {
781
- height:100%;
782
- overflow:auto;
783
- margin:0;
784
- padding:0;
785
- background:#ffffff;
786
- }
787
- body#media-upload .panel {
788
- position:relative;
789
- height:100%;
790
- overflow:auto;
791
- margin:0;
792
- border-radius:0;
793
- border-top:none;
794
- }
795
- body#media-upload .panel-heading {
796
- position:relative;
797
- z-index:100;
798
- }
799
- body#media-upload .panel-body {
800
- position:absolute;
801
- top:55px;
802
- bottom:0;
803
- width:100%;
804
- overflow:hidden;
805
- z-index:50;
806
- padding-top:0;
807
- padding-bottom:0;
808
- }
809
- body#media-upload .panel-body > .row {
810
- height:100%;
811
- }
812
- body#media-upload .panel-body > .row > div {
813
- height:100%;
814
- overflow:auto;
815
- padding-top:15px;
816
- padding-bottom:15px;
817
- }
818
- body#media-upload .panel-body .list-group-item {
819
- border-width:0;
820
- border-top-width:1px;
821
- margin:0;
822
- }
823
- body#media-upload .panel-body .list-group-item:first-child {
824
- border-width:0;
825
- }
826
- body#media-upload .term-list-item .term-images img {
827
- height:30px;
828
- }
829
- body#media-upload .term-list-item .term-label .no-checkbox {
830
- display:inline-block;
831
- width:100%;
832
- margin:10px 0;
833
- }
834
- body#media-upload .term-list-item .term-info {
835
- display:none;
836
- }
837
- .blank-aligner {
838
- display:inline-block;
839
- height:40px;
840
- vertical-align:middle;
841
- width:1px;
842
- overflow:hidden;
843
- margin-right:-2em;
844
- }
845
- body#media-upload .media-upload-sidebar {
846
- border-left:1px solid #cccccc;
847
- background-color:#eeeeee;
848
- padding:0 !important;
849
- position:relative;
850
- }
851
- body#media-upload .media-upload-sidebar form {
852
- display:-webkit-box;
853
- display:-moz-box;
854
- display:-ms-flexbox;
855
- display:-webkit-flex;
856
- display:flex;
857
- -webkit-flex-direction:column;
858
- -moz-flex-direction:column;
859
- -ms-flex-direction:column;
860
- flex-direction:column;
861
- height:100%;
862
- width:100%;
863
- }
864
- body#media-upload .media-upload-sidebar .media-upload-form-container {
865
- -webkit-box-flex:1 auto;
866
- -moz-box-flex:1 auto;
867
- -webkit-flex:1 auto;
868
- -ms-flex:1 auto;
869
- flex:1 auto;
870
- overflow:auto;
871
- padding:15px;
872
- }
873
- body#media-upload .media-upload-sidebar .panel-footer {
874
- min-height:57px;
875
- }
876
- body#media-upload .thumbnail {
877
- margin:0 5px 5px 0;
878
- position:relative;
879
- display:inline-block;
880
- }
881
- body#media-upload .thumbnail.active {
882
- background-color:lightblue;
883
- border-color:cadetblue;
884
- }
885
- body#media-upload .thumbnail .glyphicon {
886
- display:none;
887
- position:absolute;
888
- right:-3px;
889
- top:-7px;
890
- font-size:30px;
891
- }
892
- body#media-upload .thumbnail.active .glyphicon {
893
- display:inline-block;
894
- }
895
- body#media-upload .plupload_wrapper {
896
- height:100%;
897
- box-sizing:border-box;
898
- }
899
- .addtags-gap { height:200px; }
900
- body#media-upload div#pluploadUploader .plupload_container {
901
- height:100%;
902
- min-height:inherit !important;
903
- }
904
- body#media-upload .ui-resizable-handle {
905
- display:none !important;
906
- bottom:-1px;
907
- }
908
- #gmedia-post-thumbnail {
909
- font-size:12px;
910
- padding:0;
911
- display:inline;
912
- white-space:normal;
913
- }
914
- body.gmedia-blank.image_editor {
915
- height:100%;
916
- overflow:auto;
917
- margin:0;
918
- padding:0
919
- }
920
- body.gmedia-blank.image_editor .panel,
921
- body.gmedia-blank.map_editor .panel {
922
- position:relative;
923
- height:100%;
924
- overflow:auto;
925
- margin:0;
926
- }
927
- body.gmedia-blank .panel-heading {
928
- position:relative;
929
- z-index:100;
930
- }
931
- body.gmedia-blank.image_editor .panel-body {
932
- position:absolute;
933
- top:55px;
934
- bottom:0;
935
- width:100%;
936
- overflow:hidden;
937
- z-index:50;
938
- padding-top:0;
939
- padding-bottom:0;
940
- }
941
- body.gmedia-blank.image_editor .panel-body .row {
942
- height:100%;
943
- }
944
- body.gmedia-blank.image_editor .panel-body .row > div {
945
- height:100%;
946
- overflow:auto;
947
- padding-top:15px;
948
- padding-bottom:15px;
949
- }
950
- body.gmedia-blank .media-edit-sidebar {
951
- border-left:1px solid #cccccc;
952
- background-color:#eeeeee;
953
- padding:0 0 55px 0 !important;
954
- position:relative;
955
- }
956
- body.gmedia-blank #media-edit-form-container {
957
- height:100%;
958
- overflow:auto;
959
- padding:15px;
960
- }
961
- body.gmedia-blank .media-edit-sidebar .panel-footer {
962
- position:absolute;
963
- left:0;
964
- bottom:0;
965
- right:0;
966
- }
967
- #map-floating-panel {
968
- position:absolute;
969
- top:15px;
970
- right:15px;
971
- z-index:5;
972
- background-color:#fff;
973
- padding:0 0 5px 5px;
974
- width:250px;
975
- }
976
- #gallery_preview_ {
977
- width:200%;
978
- height:800px;
979
- margin-bottom:-400px;
980
- overflow:auto;
981
- -moz-transform:scale(0.5, 0.5);
982
- -webkit-transform:scale(0.5, 0.5);
983
- -o-transform:scale(0.5, 0.5);
984
- -ms-transform:scale(0.5, 0.5);
985
- transform:scale(0.5, 0.5);
986
- -moz-transform-origin:top left;
987
- -webkit-transform-origin:top left;
988
- -o-transform-origin:top left;
989
- -ms-transform-origin:top left;
990
- transform-origin:top left;
991
- border:solid #ccc 2px;
992
- }
993
- #gallery_preview {
994
- width:100%;
995
- height:600px;
996
- border:solid #ccc 1px;
997
- overflow:auto;
998
- }
999
- #adv-settings {
1000
- overflow:hidden;
1001
- }
1002
- #screen-meta .form-group {
1003
- padding-bottom:10px;
1004
- }
1005
- #previewModal {
1006
- z-index:9999;
1007
- overflow-x:auto;
1008
- }
1009
- input.sharelink[readonly] { cursor:text; }
1010
- fieldset.gmediacustomstuff { margin:0 0 10px; padding:.35em .625em .4em; position:relative; border:1px solid silver }
1011
- .delete-custom-field { margin:4px 2px 0; cursor:pointer; }
1012
- .newcustomfield-modal { position:absolute; bottom:-0.6em; right:8px; font-size:95%; }
1013
- @media (min-width:782px) {
1014
- div.modal {
1015
- top:32px;
1016
- }
1017
- div#termsModal .modal-dialog {
1018
- width:350px;
1019
- }
1020
-
1021
- }
1022
- @media (max-width:600px) {
1023
- .panel-floatingHeader .panel-heading,
1024
- .panel-absoluteHeader .panel-heading {
1025
- position:static;
1026
- box-shadow:none;
1027
- }
1028
- .panel-floatingHeader .panel-heading-fake, .panel-absoluteHeader .panel-heading-fake {
1029
- display:none;
1030
- }
1031
- }
1032
- @media (max-width:782px) {
1033
- .panel-floatingHeader .panel-heading {
1034
- top:46px;
1035
- }
1036
- div#wpwrap {
1037
- background:#708090;
1038
- }
1039
- div#wpbody select.input-sm {
1040
- height:30px;
1041
- font-size:12px;
1042
- }
1043
- #adminmenu #toplevel_page_GrandMedia ul.wp-submenu {
1044
- display:block;
1045
- }
1046
- .media-body { display:block; }
1047
- .show-settings-link { display:none; }
1048
- }
1049
- @media (max-width:991px) {
1050
- body#media-upload .panel-body > #gmUpload.row {
1051
- overflow-y:auto;
1052
- }
1053
- body#media-upload .panel-body > #gmUpload.row > div {
1054
- height:auto;
1055
- }
1056
- body#media-upload .plupload_wrapper {
1057
- height:auto;
1058
- }
1059
- body#media-upload div#pluploadUploader .plupload_container {
1060
- height:auto;
1061
- min-height:300px !important;
1062
- }
1063
- }
1064
-
1065
- /*@-moz-document url-prefix() {
1066
- a.btn, span.btn {
1067
- line-height:1.56;
1068
- }
1069
- }*/
1070
-
1071
- /* custom inclusion of right, left tabs */
1072
- .tabs-right > .nav-tabs,
1073
- .tabs-left > .nav-tabs {
1074
- border-bottom:0;
1075
- }
1076
- .gm-tab-content > .tab-pane,
1077
- .pill-content > .pill-pane {
1078
- display:none;
1079
- }
1080
- .gm-tab-content > .active,
1081
- .pill-content > .active {
1082
- display:block;
1083
- }
1084
- .tabs-left > .nav-tabs > li,
1085
- .tabs-right > .nav-tabs > li {
1086
- float:none;
1087
- }
1088
- .tabs-left > .nav-tabs > li > a,
1089
- .tabs-right > .nav-tabs > li > a {
1090
- min-width:74px;
1091
- margin-right:0;
1092
- margin-bottom:3px;
1093
- }
1094
- .tabs-left > .nav-tabs {
1095
- float:left;
1096
- margin-right:19px;
1097
- border-right:1px solid #ddd;
1098
- }
1099
- .tabs-left > .nav-tabs > li > a {
1100
- margin-right:-1px;
1101
- -webkit-border-radius:4px 0 0 4px;
1102
- -moz-border-radius:4px 0 0 4px;
1103
- border-radius:4px 0 0 4px;
1104
- }
1105
- .no-touch .tabs-left > .nav-tabs > li > a:hover,
1106
- .tabs-left > .nav-tabs > li > a:focus {
1107
- border-color:#eeeeee #dddddd #eeeeee #eeeeee;
1108
- }
1109
- .tabs-left > .nav-tabs .active > a,
1110
- .no-touch .tabs-left > .nav-tabs .active > a:hover,
1111
- .tabs-left > .nav-tabs .active > a:focus {
1112
- border-color:#ddd transparent #ddd #ddd;
1113
- *border-right-color:#ffffff;
1114
- }
1115
- .tabs-right > .nav-tabs {
1116
- float:right;
1117
- margin-left:19px;
1118
- border-left:1px solid #ddd;
1119
- }
1120
- .tabs-right > .nav-tabs > li > a {
1121
- margin-left:-1px;
1122
- -webkit-border-radius:0 4px 4px 0;
1123
- -moz-border-radius:0 4px 4px 0;
1124
- border-radius:0 4px 4px 0;
1125
- }
1126
- .no-touch .tabs-right > .nav-tabs > li > a:hover,
1127
- .tabs-right > .nav-tabs > li > a:focus {
1128
- border-color:#eeeeee #eeeeee #eeeeee #dddddd;
1129
- }
1130
- .tabs-right > .nav-tabs .active > a,
1131
- .no-touch .tabs-right > .nav-tabs .active > a:hover,
1132
- .tabs-right > .nav-tabs .active > a:focus {
1133
- border-color:#ddd #ddd #ddd transparent;
1134
- *border-left-color:#ffffff;
1135
- }
1136
-
1137
- /* custom *-xs size for form elements */
1138
- input[type="date"].input-xs,
1139
- input[type="time"].input-xs,
1140
- input[type="datetime-local"].input-xs,
1141
- input[type="month"].input-xs,
1142
- .input-group-xs input[type="date"],
1143
- .input-group-xs input[type="time"],
1144
- .input-group-xs input[type="datetime-local"],
1145
- .input-group-xs input[type="month"] {
1146
- line-height: 22px;
1147
- }
1148
- .form-control-static.input-xs {
1149
- padding-right: 0;
1150
- padding-left: 0;
1151
- }
1152
- .input-xs {
1153
- height: 22px;
1154
- padding: 1px 5px !important;
1155
- font-size: 12px;
1156
- line-height: 1.5;
1157
- border-radius: 3px;
1158
- }
1159
- select.input-xs {
1160
- height: 22px;
1161
- line-height: 22px;
1162
- }
1163
- textarea.input-xs,
1164
- select[multiple].input-xs {
1165
- height: auto;
1166
- }
1167
- .form-group-xs .form-control {
1168
- height: 22px;
1169
- padding: 1px 5px;
1170
- font-size: 12px;
1171
- line-height: 1.5;
1172
- border-radius: 3px;
1173
- }
1174
- select.form-group-xs .form-control {
1175
- height: 22px;
1176
- line-height: 22px;
1177
- }
1178
- textarea.form-group-xs .form-control,
1179
- select[multiple].form-group-xs .form-control {
1180
- height: auto;
1181
- }
1182
- .form-group-xs .form-control-static {
1183
- height: 22px;
1184
- min-height: 25px;
1185
- padding: 1px 5px;
1186
- font-size: 12px;
1187
- line-height: 1.5;
1188
- }
1189
- .input-xs + .form-control-feedback {
1190
- width: 22px;
1191
- height: 22px;
1192
- line-height: 22px;
1193
- }
1194
- @media (min-width: 768px) {
1195
- .form-horizontal .form-group-xs .control-label {
1196
- padding-top: 4px;
1197
- }
1198
- }
1199
- .input-group-xs > .form-control,
1200
- .input-group-xs > .input-group-addon,
1201
- .input-group-xs > .input-group-btn > .btn {
1202
- height: 22px;
1203
- padding: 1px 5px;
1204
- font-size: 12px;
1205
- line-height: 1.5;
1206
- border-radius: 3px;
1207
- }
1208
- select.input-group-xs > .form-control,
1209
- select.input-group-xs > .input-group-addon,
1210
- select.input-group-xs > .input-group-btn > .btn {
1211
- height: 22px;
1212
- line-height: 22px;
1213
- }
1214
- textarea.input-group-xs > .form-control,
1215
- textarea.input-group-xs > .input-group-addon,
1216
- textarea.input-group-xs > .input-group-btn > .btn,
1217
- select[multiple].input-group-xs > .form-control,
1218
- select[multiple].input-group-xs > .input-group-addon,
1219
- select[multiple].input-group-xs > .input-group-btn > .btn {
1220
- height: auto;
1221
- }
1222
- .input-group-addon.input-xs {
1223
- padding: 1px 5px;
1224
- font-size: 12px;
1225
- border-radius: 3px;
1226
- }
1227
- .input-group .form-control:first-child,
1228
- .input-group-addon:first-child,
1229
- .input-group-btn:first-child > .btn,
1230
- .input-group-btn:first-child > .btn-group > .btn,
1231
- .input-group-btn:first-child > .dropdown-toggle,
1232
- .input-group-btn:last-child > .btn-group:not(:last-child) > .btn,
1233
- .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle) {
1234
- border-bottom-right-radius: 0;
1235
- border-top-right-radius: 0;
1236
- }
1237
- .input-group .form-control:last-child,
1238
- .input-group-addon:last-child,
1239
- .input-group-btn:first-child > .btn-group:not(:first-child) > .btn,
1240
- .input-group-btn:first-child > .btn:not(:first-child),
1241
- .input-group-btn:last-child > .btn,
1242
- .input-group-btn:last-child > .btn-group > .btn,
1243
- .input-group-btn:last-child > .dropdown-toggle {
1244
- border-bottom-left-radius: 0;
1245
- border-top-left-radius: 0;
1246
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/galleries.php CHANGED
@@ -45,11 +45,30 @@ function gmediaGalleries()
45
  $taxonomy = 'gmedia_gallery';
46
  $gmediaTerms = $gmDB->get_terms($taxonomy, $args);
47
  if (is_wp_error($gmediaTerms)) {
48
- echo $gmProcessor->alert('danger', $gmediaTerms->get_error_message());
49
  $gmediaTerms = array();
50
  }
51
 
52
- $modules = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  if (($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
54
  foreach ($plugin_modules as $path) {
55
  $mfold = basename($path);
@@ -70,25 +89,19 @@ function gmediaGalleries()
70
  );
71
  }
72
  }
 
73
  ?>
74
 
75
  <div class="panel panel-default panel-fixed-header">
76
  <div class="panel-heading-fake"></div>
77
  <div class="panel-heading clearfix">
78
- <form class="form-inline gmedia-search-form" role="search" method="get">
79
- <div class="form-group">
80
- <?php foreach ($_GET as $key => $value) {
81
- if (in_array($key, array('orderby', 'order', 'number', 'global'))) {
82
- ?>
83
- <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"/>
84
- <?php
85
- }
86
- } ?>
87
- <input id="gmedia-search" class="form-control input-sm" type="text" name="s" placeholder="<?php _e('Search...', 'grand-media'); ?>" value="<?php echo $gmCore->_get('s', ''); ?>"/>
88
- </div>
89
- <button type="submit" class="btn btn-default input-sm"><span class="glyphicon glyphicon-search"></span></button>
90
- </form>
91
- <?php echo $gmDB->query_pager(); ?>
92
 
93
  <div class="btn-toolbar pull-left">
94
  <div class="btn-group gm-checkgroup" id="cb_global-btn">
@@ -172,7 +185,7 @@ function gmediaGalleries()
172
  $is_selected = in_array($term->term_id, $gmProcessor->selected_items) ? true : false;
173
 
174
  $list_row_class = '';
175
- if ('public' != $term->status) {
176
  if ('private' == $term->status) {
177
  $list_row_class = ' list-group-item-info';
178
  } elseif ('draft' == $term->status) {
@@ -215,17 +228,17 @@ function gmediaGalleries()
215
  echo '<a title="' . __('Filter in Gmedia Library', 'grand-media') . '" href="#">'.$filter_icon.'</a>';
216
  */
217
 
218
- $gmedia_hashid = gmedia_hash_id_encode($term->term_id, 'gallery');
219
- if (get_option('permalink_structure')) {
220
- $cloud_link = home_url(urlencode($endpoint) . '/g/' . $gmedia_hashid);
221
  } else {
222
- $cloud_link = add_query_arg(array("$endpoint" => $gmedia_hashid, 't' => 'g'), home_url('index.php'));
223
  }
224
  $share_icon = '<span class="glyphicon glyphicon-share"></span>';
225
  $new_window_icon = '<span class="glyphicon glyphicon-new-window"></span>';
226
  if ('draft' !== $term->status) {
227
- echo '<a target="_blank" data-target="#shareModal" data-share="' . $term->term_id . '" class="share-modal" title="' . __('Share', 'grand-media') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
228
- echo '<a target="_blank" title="' . __('GmediaCloud Page', 'grand-media') . '" href="' . $cloud_link . '">' . $new_window_icon . '</a>';
229
  } else {
230
  echo "<span class='action-inactive'>$share_icon</span>";
231
  echo "<span class='action-inactive'>$new_window_icon</span>";
@@ -371,34 +384,10 @@ function gmediaGalleries()
371
  </div>
372
  </div>
373
 
374
- <div class="modal fade gmedia-modal" id="shareModal" tabindex="-1" role="dialog" aria-hidden="true">
375
- <div class="modal-dialog">
376
- <div class="modal-content">
377
- <div class="modal-header">
378
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
379
- <h4 class="modal-title"><?php _e('GmediaCloud Page'); ?></h4>
380
- </div>
381
- <form class="modal-body" method="post" id="shareForm">
382
- <div class="form-group">
383
- <label><?php _e('Link to page', 'grand-media'); ?></label>
384
- <input name="sharelink" type="text" class="form-control sharelink" readonly="readonly" value=""/>
385
- </div>
386
- <div class="form-group">
387
- <label><?php _e('Send this link to', 'grand-media'); ?></label>
388
- <input name="email" type="email" class="form-control sharetoemail" value="" placeholder="<?php _e('Email', 'grand-media'); ?>"/>
389
- <textarea name="message" cols="20" rows="3" class="form-control" placeholder="<?php _e('Message (optional)', 'grand-media'); ?>"></textarea>
390
- </div>
391
- <input type="hidden" name="action" value="gmedia_share_page"/>
392
- <?php wp_nonce_field('share_modal', '_sharenonce'); ?>
393
- </form>
394
- <div class="modal-footer">
395
- <button type="button" class="btn btn-primary sharebutton" disabled="disabled"><?php _e('Send', 'grand-media'); ?></button>
396
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
397
- </div>
398
- </div>
399
- </div>
400
- </div>
401
  <?php
 
 
 
402
  }
403
 
404
  /**
@@ -427,7 +416,7 @@ function gmediaGalleryEdit()
427
  'name' => '',
428
  'description' => '',
429
  'global' => $author,
430
- 'status' => 'public',
431
  '_edited' => '&#8212;',
432
  '_module' => '',
433
  '_query' => array(),
@@ -470,13 +459,32 @@ function gmediaGalleryEdit()
470
  }
471
 
472
  if (! empty($alert)) {
473
- echo $gmProcessor->alert('danger', $alert);
474
  gmediaGalleries();
475
 
476
  return;
477
  }
478
 
479
- $modules = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  if (($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
481
  foreach ($plugin_modules as $path) {
482
  $mfold = basename($path);
@@ -500,6 +508,8 @@ function gmediaGalleryEdit()
500
  }
501
  }
502
 
 
 
503
  $default_options = array();
504
  $presets = false;
505
  $default_preset = array();
@@ -556,12 +566,12 @@ function gmediaGalleryEdit()
556
  }
557
 
558
  if (! empty($alert)) {
559
- echo $gmProcessor->alert('danger', $alert);
560
  }
561
 
562
  if (! empty($load_preset)) {
563
  $gallery['_settings'][$module_name] = $gmCore->array_replace_recursive($gallery['_settings'][$module_name], $load_preset);
564
- echo $gmProcessor->alert('info', sprintf(__('Preset `%s` loaded. To apply it for current gallery click Save button'), $load_preset['name']));
565
  }
566
  if (isset($gallery['_settings'][$module_name])) {
567
  $gallery_settings = $gmCore->array_replace_recursive($default_options, $gallery['_settings'][$module_name]);
@@ -689,7 +699,7 @@ function gmediaGalleryEdit()
689
  <div class="form-group">
690
  <label><?php _e('Status', 'grand-media'); ?></label>
691
  <select name="gallery[status]" class="form-control input-sm">
692
- <option value="public"<?php selected($gallery['status'], 'public'); ?>><?php _e('Public', 'grand-media'); ?></option>
693
  <option value="private"<?php selected($gallery['status'], 'private'); ?>><?php _e('Private', 'grand-media'); ?></option>
694
  <option value="draft"<?php selected($gallery['status'], 'draft'); ?>><?php _e('Draft', 'grand-media'); ?></option>
695
  </select>
@@ -777,7 +787,7 @@ function gmediaGalleryEdit()
777
  if (count($gm_terms)) {
778
  foreach ($gm_terms as $term) {
779
  $selected = (isset($gallery['_query'][$term_type]) && in_array($term->term_id, $gallery['_query'][$term_type])) ? ' selected="selected"' : '';
780
- $terms_items .= '<option value="' . $term->term_id . '"' . $selected . '>' . esc_html($term->name) . ('public' == $term->status ? '' : " [{$term->status}]") . ' &nbsp; (' . $term->count . ')</option>' . "\n";
781
  }
782
  }
783
  $setvalue = isset($gallery['_query'][$term_type]) ? 'data-setvalue="' . implode(',', $gallery['_query'][$term_type]) . '"' : '';
@@ -817,9 +827,7 @@ function gmediaGalleryEdit()
817
  </select>
818
 
819
  <p class="help-block"><?php _e('Filter - is custom query with multiple parameters.', 'grand-media'); ?>
820
- <a target="_blank" href="<?php echo add_query_arg(array('page' => 'GrandMedia_Terms',
821
- 'edit_filter' => '0'
822
- ), admin_url('admin.php')); ?>"><?php _e('Create Filter', 'grand-media'); ?></a></p>
823
  </div>
824
  <?php } ?>
825
 
@@ -863,6 +871,12 @@ function gmediaGalleryEdit()
863
  } ?>
864
  <br/><a target="_blank" href="<?php echo $gallery_link; ?>"><?php echo $gallery_link; ?></a>
865
  </p>
 
 
 
 
 
 
866
  <div class="help-block">
867
  <?php _e('update <a href="options-permalink.php">Permalink Settings</a> if above link not working', 'grand-media'); ?>
868
  <?php if (current_user_can('manage_options')) {
@@ -1066,7 +1080,7 @@ function gmediaGalleryEdit()
1066
  <div class="modal-body linkblock">
1067
  <?php
1068
  if (! empty($alert)) {
1069
- echo $gmProcessor->alert('danger', $alert);
1070
  }
1071
 
1072
  $current_module = $module_name;
45
  $taxonomy = 'gmedia_gallery';
46
  $gmediaTerms = $gmDB->get_terms($taxonomy, $args);
47
  if (is_wp_error($gmediaTerms)) {
48
+ echo $gmCore->alert('danger', $gmediaTerms->get_error_message());
49
  $gmediaTerms = array();
50
  }
51
 
52
+ $modules = array(
53
+ 'phantom' => ''
54
+ , 'phototravlr' => ''
55
+ , 'realslider' => ''
56
+ , 'mosaic' => ''
57
+ , 'photobox' => ''
58
+ , 'photomania' => ''
59
+ , 'jq-mplayer' => ''
60
+ , 'wp-videoplayer' => ''
61
+ , 'photo-pro' => ''
62
+ , 'optima' => ''
63
+ , 'afflux' => ''
64
+ , 'slider' => ''
65
+ , 'green-style' => ''
66
+ , 'photo-blog' => ''
67
+ , 'minima' => ''
68
+ , 'sphere' => ''
69
+ , 'cube' => ''
70
+ , 'flatwall' => ''
71
+ );
72
  if (($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
73
  foreach ($plugin_modules as $path) {
74
  $mfold = basename($path);
89
  );
90
  }
91
  }
92
+ $modules = array_filter($modules);
93
  ?>
94
 
95
  <div class="panel panel-default panel-fixed-header">
96
  <div class="panel-heading-fake"></div>
97
  <div class="panel-heading clearfix">
98
+
99
+ <?php
100
+
101
+ include(dirname(__FILE__) . '/tpl/search-form.php');
102
+
103
+ echo $gmDB->query_pager();
104
+ ?>
 
 
 
 
 
 
 
105
 
106
  <div class="btn-toolbar pull-left">
107
  <div class="btn-group gm-checkgroup" id="cb_global-btn">
185
  $is_selected = in_array($term->term_id, $gmProcessor->selected_items) ? true : false;
186
 
187
  $list_row_class = '';
188
+ if ('publish' != $term->status) {
189
  if ('private' == $term->status) {
190
  $list_row_class = ' list-group-item-info';
191
  } elseif ('draft' == $term->status) {
228
  echo '<a title="' . __('Filter in Gmedia Library', 'grand-media') . '" href="#">'.$filter_icon.'</a>';
229
  */
230
 
231
+ $cloud_link = $gmCore->gmcloudlink($term->term_id, 'gallery');
232
+ if(!empty($term_meta['_post_ID'])){
233
+ $post_link = get_permalink($term_meta['_post_ID']);
234
  } else {
235
+ $post_link = '';
236
  }
237
  $share_icon = '<span class="glyphicon glyphicon-share"></span>';
238
  $new_window_icon = '<span class="glyphicon glyphicon-new-window"></span>';
239
  if ('draft' !== $term->status) {
240
+ echo '<a target="_blank" data-target="#shareModal" data-share="' . $term->term_id . '" class="share-modal" title="' . __('Share', 'grand-media') . '" data-gmediacloud="' . $cloud_link . '" href="' . $post_link . '">' . $share_icon . '</a>';
241
+ //echo '<a target="_blank" title="' . __('GmediaCloud Page', 'grand-media') . '" href="' . $cloud_link . '">' . $new_window_icon . '</a>';
242
  } else {
243
  echo "<span class='action-inactive'>$share_icon</span>";
244
  echo "<span class='action-inactive'>$new_window_icon</span>";
384
  </div>
385
  </div>
386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  <?php
388
+
389
+ include(GMEDIA_ABSPATH. 'admin/tpl/modal-share.php');
390
+
391
  }
392
 
393
  /**
416
  'name' => '',
417
  'description' => '',
418
  'global' => $author,
419
+ 'status' => 'publish',
420
  '_edited' => '&#8212;',
421
  '_module' => '',
422
  '_query' => array(),
459
  }
460
 
461
  if (! empty($alert)) {
462
+ echo $gmCore->alert('danger', $alert);
463
  gmediaGalleries();
464
 
465
  return;
466
  }
467
 
468
+ $modules = array(
469
+ 'phantom' => ''
470
+ , 'phototravlr' => ''
471
+ , 'realslider' => ''
472
+ , 'mosaic' => ''
473
+ , 'photobox' => ''
474
+ , 'photomania' => ''
475
+ , 'jq-mplayer' => ''
476
+ , 'wp-videoplayer' => ''
477
+ , 'photo-pro' => ''
478
+ , 'optima' => ''
479
+ , 'afflux' => ''
480
+ , 'slider' => ''
481
+ , 'green-style' => ''
482
+ , 'photo-blog' => ''
483
+ , 'minima' => ''
484
+ , 'sphere' => ''
485
+ , 'cube' => ''
486
+ , 'flatwall' => ''
487
+ );
488
  if (($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
489
  foreach ($plugin_modules as $path) {
490
  $mfold = basename($path);
508
  }
509
  }
510
 
511
+ $modules = array_filter($modules);
512
+
513
  $default_options = array();
514
  $presets = false;
515
  $default_preset = array();
566
  }
567
 
568
  if (! empty($alert)) {
569
+ echo $gmCore->alert('danger', $alert);
570
  }
571
 
572
  if (! empty($load_preset)) {
573
  $gallery['_settings'][$module_name] = $gmCore->array_replace_recursive($gallery['_settings'][$module_name], $load_preset);
574
+ echo $gmCore->alert('info', sprintf(__('Preset `%s` loaded. To apply it for current gallery click Save button'), $load_preset['name']));
575
  }
576
  if (isset($gallery['_settings'][$module_name])) {
577
  $gallery_settings = $gmCore->array_replace_recursive($default_options, $gallery['_settings'][$module_name]);
699
  <div class="form-group">
700
  <label><?php _e('Status', 'grand-media'); ?></label>
701
  <select name="gallery[status]" class="form-control input-sm">
702
+ <option value="publish"<?php selected($gallery['status'], 'publish'); ?>><?php _e('Public', 'grand-media'); ?></option>
703
  <option value="private"<?php selected($gallery['status'], 'private'); ?>><?php _e('Private', 'grand-media'); ?></option>
704
  <option value="draft"<?php selected($gallery['status'], 'draft'); ?>><?php _e('Draft', 'grand-media'); ?></option>
705
  </select>
787
  if (count($gm_terms)) {
788
  foreach ($gm_terms as $term) {
789
  $selected = (isset($gallery['_query'][$term_type]) && in_array($term->term_id, $gallery['_query'][$term_type])) ? ' selected="selected"' : '';
790
+ $terms_items .= '<option value="' . $term->term_id . '"' . $selected . '>' . esc_html($term->name) . ('publish' == $term->status ? '' : " [{$term->status}]") . ' &nbsp; (' . $term->count . ')</option>' . "\n";
791
  }
792
  }
793
  $setvalue = isset($gallery['_query'][$term_type]) ? 'data-setvalue="' . implode(',', $gallery['_query'][$term_type]) . '"' : '';
827
  </select>
828
 
829
  <p class="help-block"><?php _e('Filter - is custom query with multiple parameters.', 'grand-media'); ?>
830
+ <a target="_blank" href="<?php echo add_query_arg(array('page' => 'GrandMedia_Terms', 'taxonomy' => 'gmedia_filter', 'edit_item' => '0'), admin_url('admin.php')); ?>"><?php _e('Create Filter', 'grand-media'); ?></a></p>
 
 
831
  </div>
832
  <?php } ?>
833
 
871
  } ?>
872
  <br/><a target="_blank" href="<?php echo $gallery_link; ?>"><?php echo $gallery_link; ?></a>
873
  </p>
874
+ <?php if(isset($gallery['_post_ID'])){ ?>
875
+ <p><b><?php _e('Gmedia Post URL for current gallery:'); ?></b>
876
+ <?php $post_link = get_permalink($gallery['_post_ID']); ?>
877
+ <br/><a target="_blank" href="<?php echo $post_link; ?>"><?php echo $post_link; ?></a>
878
+ </p>
879
+ <?php } ?>
880
  <div class="help-block">
881
  <?php _e('update <a href="options-permalink.php">Permalink Settings</a> if above link not working', 'grand-media'); ?>
882
  <?php if (current_user_can('manage_options')) {
1080
  <div class="modal-body linkblock">
1081
  <?php
1082
  if (! empty($alert)) {
1083
+ echo $gmCore->alert('danger', $alert);
1084
  }
1085
 
1086
  $current_module = $module_name;
admin/modules.php DELETED
@@ -1,209 +0,0 @@
1
- <?php
2
- if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
3
- die('You are not allowed to call this page directly.');
4
- }
5
-
6
- /**
7
- * gmediaModules()
8
- *
9
- * @return mixed content
10
- */
11
- function gmediaModules()
12
- {
13
- global $gmCore, $gmProcessor, $gmGallery;
14
-
15
- $url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
16
-
17
- $modules = array();
18
- if (($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
19
- foreach ($plugin_modules as $path) {
20
- $mfold = basename($path);
21
- $modules[$mfold] = array(
22
- 'place' => 'plugin',
23
- 'module_name' => $mfold,
24
- 'module_url' => $gmCore->gmedia_url . "/module/{$mfold}",
25
- 'module_path' => $path
26
- );
27
- }
28
- }
29
- if (($upload_modules = glob($gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
30
- foreach ($upload_modules as $path) {
31
- $mfold = basename($path);
32
- $modules[$mfold] = array(
33
- 'place' => 'upload',
34
- 'module_name' => $mfold,
35
- 'module_url' => $gmCore->upload['url'] . "/{$gmGallery->options['folder']['module']}/{$mfold}",
36
- 'module_path' => $path
37
- );
38
- }
39
- }
40
- // not installed modules
41
- $xml = array();
42
- $get_xml = wp_remote_get($gmGallery->options['modules_xml'], array('sslverify' => true));
43
- if (! is_wp_error($get_xml) && (200 == $get_xml['response']['code'])) {
44
- $xml = @simplexml_load_string($get_xml['body']);
45
- } else {
46
- $alert = array(__('Error loading remote xml...', 'grand-media'));
47
- if (is_wp_error($get_xml)) {
48
- $alert[] = $get_xml->get_error_message();
49
- }
50
- echo $gmProcessor->alert('danger', $alert);
51
- }
52
-
53
- if (! empty($xml)) {
54
- foreach ($xml as $m) {
55
- $name = (string)$m->name;
56
- $xml_modules[$name] = get_object_vars($m);
57
- }
58
- }
59
-
60
- ?>
61
- <div id="gmedia_modules">
62
- <div class="panel panel-default">
63
- <div class="panel-heading clearfix">
64
- <a href="#installModuleModal" class="btn btn-primary pull-right<?php echo current_user_can('manage_options')? '' : ' disabled'; ?>" data-toggle="modal"><?php _e('Install Module ZIP'); ?></a>
65
-
66
- <h3 class="panel-title"><?php _e('Installed Modules', 'grand-media'); ?></h3>
67
- </div>
68
- <div class="panel-body" id="gmedia-msg-panel"></div>
69
- <div class="panel-body">
70
- <?php
71
- // installed modules
72
- if (! empty($modules)) {
73
- foreach ($modules as $m) {
74
- /**
75
- * @var $place
76
- * @var $module_name
77
- * @var $module_url
78
- * @var $module_path
79
- */
80
- extract($m);
81
-
82
- // todo: get broken modules folders and delete them with files in modules root
83
- if (! file_exists($module_path . '/index.php')) {
84
- continue;
85
- }
86
-
87
- $module_info = array();
88
- /** @noinspection PhpIncludeInspection */
89
- include($module_path . '/index.php');
90
- if (empty($module_info)) {
91
- continue;
92
- }
93
-
94
- $m = isset($xml_modules[$module_name]) ? array_merge($module_info, $xml_modules[$module_name]) : $module_info;
95
- $mclass = ' module-' . $m['type'] . ' module-' . $m['status'];
96
-
97
- $update_button = '';
98
- if (isset($xml_modules[$module_name])) {
99
- if (version_compare((float)$xml_modules[$module_name]['version'], (float)$module_info['version'], '>')) {
100
- $update_button = '<a class="btn btn-warning module_install" data-module="' . $module_name . '" data-loading-text="' . __('Loading...', 'grand-media') . '" href="' . esc_url($xml_modules[$module_name]['download']) . '">' . __('Update Module', 'grand-media') . " (v{$xml_modules[$module_name]['version']})</a>";
101
- $mclass .= ' module-update';
102
- } else {
103
- unset($xml_modules[$module_name]);
104
- }
105
- }
106
- ?>
107
- <div class="media<?php echo $mclass; ?>">
108
- <div class="thumbnail pull-left">
109
- <img class="media-object" src="<?php echo $module_url . '/screenshot.png'; ?>" alt="<?php echo esc_attr($m['title']); ?>" width="320" height="240"/>
110
- </div>
111
- <div class="media-body" style="margin-left:340px;">
112
- <h4 class="media-heading"><?php echo $m['title']; ?></h4>
113
-
114
- <p class="version"><?php echo __('Version', 'grand-media') . ': ' . $module_info['version']; ?></p>
115
-
116
- <div class="description"><?php echo str_replace("\n", '<br />', (string)$m['description']); ?></div>
117
- <hr/>
118
- <p class="buttons">
119
- <a class="btn btn-success" href="<?php echo $gmCore->get_admin_url(array( 'page' => 'GrandMedia_Galleries', 'gallery_module' => $module_name), array(), true); ?>"><?php _e('Create Gallery', 'grand-media'); ?></a>
120
- <?php if (! empty($m['demo']) && $m['demo'] != '#') { ?>
121
- <a class="btn btn-default" target="_blank" href="<?php echo $m['demo']; ?>"><?php _e('View Demo', 'grand-media') ?></a>
122
- <?php } ?>
123
- <?php echo $update_button; ?>
124
- <?php if (('upload' == $place) && $gmCore->caps['gmedia_module_manage']) { ?>
125
- <a class="btn btn-danger" href="<?php echo wp_nonce_url($gmCore->get_admin_url(array( 'delete_module' => $module_name), array(), $url), 'gmedia_module_delete'); ?>"><?php _e('Delete Module', 'grand-media'); ?></a>
126
- <?php } ?>
127
- <?php if (! empty($m['download'])) { ?>
128
- <a class="btn btn-link" href="<?php echo $m['download']; ?>" download="true"><?php _e('Download module ZIP', 'grand-media') ?></a>
129
- <?php } ?>
130
- </p>
131
- </div>
132
- </div>
133
- <?php
134
- }
135
- }
136
- ?>
137
- </div>
138
- </div>
139
-
140
- <?php if (! empty($xml_modules)) { ?>
141
- <div class="panel panel-default">
142
- <div class="panel-heading clearfix">
143
- <h3 class="panel-title"><?php _e('Not Installed Modules', 'grand-media'); ?></h3>
144
- </div>
145
- <div class="panel-body" id="gmedia-msg-panel"></div>
146
- <div class="panel-body">
147
- <?php
148
- $xml_dirpath = dirname($gmGallery->options['modules_xml']);
149
- foreach ($xml_modules as $m) {
150
- if (empty($m)) {
151
- continue;
152
- }
153
- $mclass = ' module-' . $m['type'] . ' module-' . $m['status'];
154
- ?>
155
- <div class="media<?php echo $mclass; ?>">
156
- <div class="thumbnail pull-left">
157
- <img class="media-object" src="<?php echo $xml_dirpath . '/' . $m['name']; ?>.png" alt="<?php echo esc_attr($m['title']); ?>" width="320" height="240"/>
158
- </div>
159
- <div class="media-body" style="margin-left:340px;">
160
- <h4 class="media-heading"><?php echo $m['title']; ?></h4>
161
-
162
- <p class="version"><?php echo __('Version', 'grand-media') . ': ' . $m['version']; ?></p>
163
-
164
- <div class="description"><?php echo str_replace("\n", '<br />', (string)$m['description']); ?></div>
165
- <hr/>
166
- <p class="buttons">
167
- <a class="btn btn-primary <?php echo $gmCore->caps['gmedia_module_manage'] ? 'module_install' : 'disabled'; ?>" data-module="<?php echo $m['name']; ?>" data-loading-text="<?php _e('Loading...', 'grand-media'); ?>" href="<?php echo $m['download']; ?>"><?php _e('Install Module', 'grand-media'); ?></a>
168
- <?php if (! empty($m['demo']) && $m['demo'] != '#') { ?>
169
- <a class="btn btn-default" target="_blank" href="<?php echo $m['demo']; ?>"><?php _e('View Demo', 'grand-media') ?></a>
170
- <?php } ?>
171
- <?php if (! empty($m['download'])) { ?>
172
- <a class="btn btn-link" href="<?php echo $m['download']; ?>" download="true"><?php _e('Download module ZIP', 'grand-media') ?></a>
173
- <?php } ?>
174
- </p>
175
- </div>
176
- </div>
177
- <?php } ?>
178
- </div>
179
- </div>
180
- <?php } ?>
181
- </div>
182
-
183
- <?php if ($gmCore->caps['gmedia_module_manage']) { ?>
184
- <!-- Modal -->
185
- <div class="modal fade gmedia-modal" id="installModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
186
- <div class="modal-dialog">
187
- <form class="modal-content" method="post" enctype="multipart/form-data" action="<?php echo $url; ?>">
188
- <div class="modal-header">
189
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
190
- <h4 class="modal-title"><?php _e('Install a plugin in .zip format'); ?></h4>
191
- </div>
192
- <div class="modal-body">
193
- <p class="install-help"><?php _e('If you have a module in a .zip format, you may install it by uploading it here.'); ?></p>
194
- <?php wp_nonce_field('GmediaModule'); ?>
195
- <label class="screen-reader-text" for="modulezip"><?php _e('Module zip file'); ?></label>
196
- <input type="file" id="modulezip" name="modulezip"/>
197
- </div>
198
- <div class="modal-footer">
199
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Cancel', 'grand-media'); ?></button>
200
- <button type="submit" class="btn btn-primary"><?php _e('Install', 'grand-media'); ?></button>
201
- </div>
202
- </form>
203
- </div>
204
- </div>
205
- <?php } ?>
206
-
207
- <?php
208
- }
209
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/{addmedia → pages/addmedia}/addmedia.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Gmedia Library
4
  */
5
 
6
  // don't load directly
@@ -8,9 +8,6 @@ if(!defined('ABSPATH')) {
8
  die('-1');
9
  }
10
 
11
- include_once(GMEDIA_ABSPATH . 'admin/functions.php');
12
- include_once(GMEDIA_ABSPATH . 'admin/addmedia/functions.php');
13
-
14
  global $user_ID, $gmGallery, $gmProcessor, $gmCore, $gmDB;
15
 
16
  $url = $gmProcessor->url;
@@ -19,15 +16,15 @@ $import = $gmProcessor->import;
19
 
20
  <div class="panel panel-default">
21
 
22
- <?php include(GMEDIA_ABSPATH . 'admin/addmedia/tpl/panel-heading.php'); ?>
23
 
24
  <div class="panel-body" id="gmedia-msg-panel"></div>
25
  <div class="container-fluid gmAddMedia">
26
  <?php
27
  if(!$import) {
28
- include(GMEDIA_ABSPATH. 'admin/addmedia/tpl/upload.php');
29
  } else {
30
- include(GMEDIA_ABSPATH. 'admin/addmedia/tpl/import.php');
31
  }
32
 
33
  wp_original_referer_field(true, 'previous');
1
  <?php
2
  /**
3
+ * Gmedia AddMedia
4
  */
5
 
6
  // don't load directly
8
  die('-1');
9
  }
10
 
 
 
 
11
  global $user_ID, $gmGallery, $gmProcessor, $gmCore, $gmDB;
12
 
13
  $url = $gmProcessor->url;
16
 
17
  <div class="panel panel-default">
18
 
19
+ <?php include(dirname(__FILE__) . '/tpl/panel-heading.php'); ?>
20
 
21
  <div class="panel-body" id="gmedia-msg-panel"></div>
22
  <div class="container-fluid gmAddMedia">
23
  <?php
24
  if(!$import) {
25
+ include(dirname(__FILE__) . '/tpl/upload.php');
26
  } else {
27
+ include(dirname(__FILE__) . '/tpl/import.php');
28
  }
29
 
30
  wp_original_referer_field(true, 'previous');
admin/{addmedia → pages/addmedia}/tpl/assign-terms.php RENAMED
File without changes
admin/{addmedia → pages/addmedia}/tpl/import.php RENAMED
@@ -27,7 +27,7 @@ $import_tab = array();
27
  <input type="hidden" name="action" value="gmedia_import_handler"/>
28
  <input type="hidden" id="import-action" name="import" value=""/>
29
 
30
- <?php include(GMEDIA_ABSPATH . 'admin/addmedia/tpl/assign-terms.php'); ?>
31
 
32
  </fieldset>
33
  </div>
27
  <input type="hidden" name="action" value="gmedia_import_handler"/>
28
  <input type="hidden" id="import-action" name="import" value=""/>
29
 
30
+ <?php include(dirname(__FILE__) . '/assign-terms.php'); ?>
31
 
32
  </fieldset>
33
  </div>
admin/{addmedia → pages/addmedia}/tpl/panel-heading.php RENAMED
File without changes
admin/{addmedia → pages/addmedia}/tpl/upload.php RENAMED
@@ -51,7 +51,7 @@ $gm_terms = array();
51
  <label><?php _e('Status', 'grand-media'); ?></label>
52
  <select name="set_status" class="form-control input-sm">
53
  <option value="inherit"><?php _e('Same as Album or Public', 'grand-media'); ?></option>
54
- <option value="public"><?php _e('Public', 'grand-media'); ?></option>
55
  <option value="private"><?php _e('Private', 'grand-media'); ?></option>
56
  <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
57
  </select>
@@ -59,7 +59,7 @@ $gm_terms = array();
59
 
60
  <hr/>
61
 
62
- <?php include(GMEDIA_ABSPATH . 'admin/addmedia/tpl/assign-terms.php'); ?>
63
 
64
  </div>
65
  <div class="col-md-8" id="pluploadUploader">
51
  <label><?php _e('Status', 'grand-media'); ?></label>
52
  <select name="set_status" class="form-control input-sm">
53
  <option value="inherit"><?php _e('Same as Album or Public', 'grand-media'); ?></option>
54
+ <option value="publish"><?php _e('Public', 'grand-media'); ?></option>
55
  <option value="private"><?php _e('Private', 'grand-media'); ?></option>
56
  <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
57
  </select>
59
 
60
  <hr/>
61
 
62
+ <?php include(dirname(__FILE__) . '/assign-terms.php'); ?>
63
 
64
  </div>
65
  <div class="col-md-8" id="pluploadUploader">
admin/{library → pages/library}/functions.php RENAMED
@@ -15,7 +15,11 @@ function gmedia_item_actions($item) {
15
 
16
  $actions = array();
17
  if(((int)$item->author == get_current_user_id()) || gm_user_can('edit_others_media')) {
18
- $cloud_link = $gmCore->gmcloudlink($item->ID, 'single');
 
 
 
 
19
  $actions['share'] = '<a target="_blank" data-target="#shareModal" data-share="' . $item->ID . '" class="share-modal" title="' . __('GmediaCloud Page', 'grand-media') . '" href="' . $cloud_link . '">' . __('Share', 'grand-media') . '</a>';
20
  if(gm_user_can('edit_media')) {
21
  $actions['edit_data'] = '<a href="' . admin_url("admin.php?page=GrandMedia&edit_mode=1&gmedia__in={$item->ID}") . '">' . __('Edit Data', 'grand-media') . '</a>';
@@ -47,7 +51,7 @@ function gmedia_item_actions($item) {
47
 
48
 
49
  function gmedia_item_more_data(&$item) {
50
- global $gmDB, $gmCore, $gmGallery, $gmProcessor;
51
 
52
  $meta = $gmDB->get_metadata('gmedia', $item->ID);
53
  $metadata = isset($meta['_metadata'][0])? $meta['_metadata'][0] : array();
@@ -72,12 +76,13 @@ function gmedia_item_more_data(&$item) {
72
  $item->url_thumb = $gmCore->upload['url'] . '/' . $gmGallery->options['folder']['image_thumb'] . '/' . $item->gmuid;
73
  $item->path_original = $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['image_original'] . '/' . $item->gmuid;
74
  $item->path_thumb = $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['image_thumb'] . '/' . $item->gmuid;
75
- if(!empty($meta['_gps'][0])) {
76
- $item->gps = implode(', ', $meta['_gps'][0]);
77
- } elseif(!empty($metadata['image_meta']['GPS'])) {
78
  $item->gps = implode(', ', $metadata['image_meta']['GPS']);
79
  }
80
  }
 
 
 
81
 
82
  $item->msize['width'] = isset($metadata['web']['width'])? $metadata['web']['width'] : (isset($metadata['width'])? $metadata['width'] : '640');
83
  $item->msize['height'] = isset($metadata['web']['height'])? $metadata['web']['height'] : (isset($metadata['height'])? $metadata['height'] : '200');
@@ -91,17 +96,6 @@ function gmedia_item_more_data(&$item) {
91
  $item->album = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_album');
92
  $item->category = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_category');
93
 
94
- $item->classes = array();
95
- if('public' != $item->status) {
96
- if('private' == $item->status) {
97
- $item->classes[] = 'list-group-item-info';
98
- } elseif('draft' == $item->status) {
99
- $item->classes[] = 'list-group-item-warning';
100
- }
101
- }
102
-
103
- $item->selected = in_array($item->ID, $gmProcessor->selected_items);
104
-
105
  $item = apply_filters('gmedia_item_more_data', $item);
106
  }
107
 
15
 
16
  $actions = array();
17
  if(((int)$item->author == get_current_user_id()) || gm_user_can('edit_others_media')) {
18
+ if(!empty($item->post_id)){
19
+ $cloud_link = get_permalink($item->post_id);
20
+ } else {
21
+ $cloud_link = $gmCore->gmcloudlink($item->ID, 'single');
22
+ }
23
  $actions['share'] = '<a target="_blank" data-target="#shareModal" data-share="' . $item->ID . '" class="share-modal" title="' . __('GmediaCloud Page', 'grand-media') . '" href="' . $cloud_link . '">' . __('Share', 'grand-media') . '</a>';
24
  if(gm_user_can('edit_media')) {
25
  $actions['edit_data'] = '<a href="' . admin_url("admin.php?page=GrandMedia&edit_mode=1&gmedia__in={$item->ID}") . '">' . __('Edit Data', 'grand-media') . '</a>';
51
 
52
 
53
  function gmedia_item_more_data(&$item) {
54
+ global $gmDB, $gmCore, $gmGallery;
55
 
56
  $meta = $gmDB->get_metadata('gmedia', $item->ID);
57
  $metadata = isset($meta['_metadata'][0])? $meta['_metadata'][0] : array();
76
  $item->url_thumb = $gmCore->upload['url'] . '/' . $gmGallery->options['folder']['image_thumb'] . '/' . $item->gmuid;
77
  $item->path_original = $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['image_original'] . '/' . $item->gmuid;
78
  $item->path_thumb = $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['image_thumb'] . '/' . $item->gmuid;
79
+ if(!empty($metadata['image_meta']['GPS'])) {
 
 
80
  $item->gps = implode(', ', $metadata['image_meta']['GPS']);
81
  }
82
  }
83
+ if(!empty($meta['_gps'][0])) {
84
+ $item->gps = implode(', ', $meta['_gps'][0]);
85
+ }
86
 
87
  $item->msize['width'] = isset($metadata['web']['width'])? $metadata['web']['width'] : (isset($metadata['width'])? $metadata['width'] : '640');
88
  $item->msize['height'] = isset($metadata['web']['height'])? $metadata['web']['height'] : (isset($metadata['height'])? $metadata['height'] : '200');
96
  $item->album = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_album');
97
  $item->category = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_category');
98
 
 
 
 
 
 
 
 
 
 
 
 
99
  $item = apply_filters('gmedia_item_more_data', $item);
100
  }
101
 
admin/{library → pages/library}/library.php RENAMED
@@ -8,9 +8,6 @@ if(!defined('ABSPATH')) {
8
  die('-1');
9
  }
10
 
11
- include_once(GMEDIA_ABSPATH. 'admin/functions.php');
12
- include_once(GMEDIA_ABSPATH. 'admin/library/functions.php');
13
-
14
  global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
15
 
16
  $gmedia_url = $gmProcessor->url;
@@ -33,7 +30,7 @@ if($gmProcessor->user_options['grid_cell_fit_gmedia']) {
33
 
34
  <div class="panel panel-default <?php gm_panel_classes($panel_class); ?>" id="gmedia-panel">
35
 
36
- <?php include(GMEDIA_ABSPATH. 'admin/library/tpl/panel-heading.php'); ?>
37
 
38
  <div class="panel-body"></div>
39
  <div class="list-group clearfix" id="gm-list-table">
@@ -46,26 +43,54 @@ if($gmProcessor->user_options['grid_cell_fit_gmedia']) {
46
  foreach($gmedia_query as &$item) {
47
  gmedia_item_more_data($item);
48
 
49
- include(GMEDIA_ABSPATH. 'admin/library/tpl/' . $gmedia_user_options['display_mode_gmedia'] . '-item.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
  } elseif(gm_user_can('edit_media')) {
52
  foreach($gmedia_query as &$item) {
53
  gmedia_item_more_data($item);
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  if(((int)$item->author != $user_ID) && !gm_user_can('edit_others_media')) {
56
- include(GMEDIA_ABSPATH. 'admin/library/tpl/list-item.php');
57
  } else {
58
- include(GMEDIA_ABSPATH. 'admin/library/tpl/edit-item.php');
59
  }
60
  }
61
  }
62
  } else {
63
- include(GMEDIA_ABSPATH. 'admin/library/tpl/no-item.php');
64
  } ?>
65
  </div>
66
 
67
  <?php
68
- include(GMEDIA_ABSPATH. 'admin/library/tpl/panel-footer.php');
69
 
70
  wp_original_referer_field(true, 'previous');
71
  wp_nonce_field('GmediaGallery');
8
  die('-1');
9
  }
10
 
 
 
 
11
  global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
 
13
  $gmedia_url = $gmProcessor->url;
30
 
31
  <div class="panel panel-default <?php gm_panel_classes($panel_class); ?>" id="gmedia-panel">
32
 
33
+ <?php include(dirname(__FILE__) . '/tpl/panel-heading.php'); ?>
34
 
35
  <div class="panel-body"></div>
36
  <div class="list-group clearfix" id="gm-list-table">
43
  foreach($gmedia_query as &$item) {
44
  gmedia_item_more_data($item);
45
 
46
+ $item->classes = array();
47
+ if('publish' != $item->status) {
48
+ if('private' == $item->status) {
49
+ $item->classes[] = 'list-group-item-info';
50
+ } elseif('draft' == $item->status) {
51
+ $item->classes[] = 'list-group-item-warning';
52
+ }
53
+ }
54
+ $item->selected = in_array($item->ID, (array)$gmProcessor->selected_items);
55
+ if($item->selected){
56
+ $item->classes[] = 'gm-selected';
57
+ }
58
+ $item->in_stack = in_array($item->ID, (array)$gmProcessor->stack_items);
59
+
60
+ include(dirname(__FILE__) . '/tpl/' . $gmedia_user_options['display_mode_gmedia'] . '-item.php');
61
  }
62
  } elseif(gm_user_can('edit_media')) {
63
  foreach($gmedia_query as &$item) {
64
  gmedia_item_more_data($item);
65
 
66
+ $item->classes = array();
67
+ if('publish' != $item->status) {
68
+ if('private' == $item->status) {
69
+ $item->classes[] = 'list-group-item-info';
70
+ } elseif('draft' == $item->status) {
71
+ $item->classes[] = 'list-group-item-warning';
72
+ }
73
+ }
74
+ $item->selected = in_array($item->ID, (array)$gmProcessor->selected_items);
75
+ if($item->selected){
76
+ $item->classes[] = 'gm-selected';
77
+ }
78
+ $item->in_stack = in_array($item->ID, (array)$gmProcessor->stack_items);
79
+
80
  if(((int)$item->author != $user_ID) && !gm_user_can('edit_others_media')) {
81
+ include(dirname(__FILE__) . '/tpl/list-item.php');
82
  } else {
83
+ include(dirname(__FILE__) . '/tpl/edit-item.php');
84
  }
85
  }
86
  }
87
  } else {
88
+ include(dirname(__FILE__) . '/tpl/no-items.php');
89
  } ?>
90
  </div>
91
 
92
  <?php
93
+ include(dirname(__FILE__) . '/tpl/panel-footer.php');
94
 
95
  wp_original_referer_field(true, 'previous');
96
  wp_nonce_field('GmediaGallery');
admin/{library → pages/library}/tpl/edit-item.php RENAMED
@@ -3,15 +3,18 @@
3
  * Edit Gmedia Item
4
  */
5
  ?>
6
- <form class="cb_list-item list-group-item row d-row edit-gmedia<?php echo ($item->selected? ' gm-selected ' : ' ') . implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>" role="form">
7
  <div class="col-sm-4" style="max-width:340px;">
8
  <input name="ID" type="hidden" value="<?php echo $item->ID; ?>"/>
9
- <label class="cb_media-object">
10
- <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" class="hidden" value="<?php echo $item->ID; ?>"/>
11
- <span data-target="<?php echo $item->url; ?>" class="thumbnail">
12
- <?php gmedia_item_thumbnail($item); ?>
13
- </span>
14
- </label>
 
 
 
15
  <div class="gmedia-actions">
16
  <?php $media_action_links = gmedia_item_actions($item);
17
  unset($media_action_links['edit_data']);
@@ -51,8 +54,8 @@
51
  <div class="col-lg-6">
52
  <?php if(('image' != $item->type)) { ?>
53
  <div class="form-group">
54
- <label><?php _e('Custom Cover', 'grand-media'); ?></label>
55
- <input name="meta[_cover]" type="text" class="form-control input-sm gmedia-cover" value="<?php echo isset($meta['_cover'][0])? $meta['_cover'][0] : ''; ?>" placeholder="<?php _e('Gmedia ID or Image URL', 'grand-media'); ?>"/>
56
  </div>
57
  <?php } ?>
58
  <?php if(gm_user_can('terms')) { ?>
@@ -100,7 +103,7 @@
100
  } else {
101
  $author_name .= ' &nbsp; (' . __('shared', 'grand-media') . ')';
102
  }
103
- if('public' != $term->status) {
104
  $author_name .= ' [' . $term->status . ']';
105
  }
106
 
@@ -156,11 +159,24 @@
156
  <div class="form-group status-item bg-status-<?php echo $item->status; ?>">
157
  <label><?php _e('Status', 'grand-media'); ?></label>
158
  <select name="status" class="form-control input-sm">
159
- <option <?php selected($item->status, 'public'); ?> value="public"><?php _e('Public', 'grand-media'); ?></option>
160
  <option <?php selected($item->status, 'private'); ?> value="private"><?php _e('Private', 'grand-media'); ?></option>
161
  <option <?php selected($item->status, 'draft'); ?> value="draft"><?php _e('Draft', 'grand-media'); ?></option>
162
  </select>
163
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  </div>
165
  <div class="col-lg-6">
166
  <div class="form-group">
@@ -190,7 +206,7 @@
190
 
191
  <div class="input-group input-group-sm">
192
  <input name="meta[_gps]" type="text" class="form-control input-sm gps_map_coordinates" value="<?php echo $item->gps; ?>" placeholder="<?php _e('Latitude, Longtitude', 'grand-media'); ?>" autocomplete="off"/>
193
- <span class="input-group-btn"><a href="<?php echo admin_url("admin.php?page=GrandMedia&gmediablank=map_editor&id={$item->ID}") ?>" class="btn btn-primary gmedit-modal" data-target="#gmeditModal">
194
  <span class="glyphicon glyphicon-map-marker"></span></a></span>
195
  </div>
196
  </div>
3
  * Edit Gmedia Item
4
  */
5
  ?>
6
+ <form class="cb_list-item list-group-item row d-row edit-gmedia <?php echo implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>" role="form">
7
  <div class="col-sm-4" style="max-width:340px;">
8
  <input name="ID" type="hidden" value="<?php echo $item->ID; ?>"/>
9
+ <div class="thumbwrap">
10
+ <label class="cb_media-object">
11
+ <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" class="hidden edit-gmedia-ignore" value="<?php echo $item->ID; ?>"/>
12
+ <span data-target="<?php echo $item->url; ?>" class="thumbnail">
13
+ <?php gmedia_item_thumbnail($item); ?>
14
+ </span>
15
+ </label>
16
+ <label class="gm-stack"><input title="<?php _e('Add to Stack', 'grand-media'); ?>" name="stack[]" type="checkbox"<?php echo $item->in_stack? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/></label>
17
+ </div>
18
  <div class="gmedia-actions">
19
  <?php $media_action_links = gmedia_item_actions($item);
20
  unset($media_action_links['edit_data']);
54
  <div class="col-lg-6">
55
  <?php if(('image' != $item->type)) { ?>
56
  <div class="form-group">
57
+ <label><?php _e('Custom Cover', 'grand-media'); echo ' <small>('.__('media image ID', 'grand-media').')</small>'; ?></label>
58
+ <input name="meta[_cover]" type="text" class="form-control input-sm gmedia-cover" value="<?php echo isset($item->meta['_cover'][0])? $item->meta['_cover'][0] : ''; ?>" placeholder="<?php _e('Gmedia ID or Image URL', 'grand-media'); ?>"/>
59
  </div>
60
  <?php } ?>
61
  <?php if(gm_user_can('terms')) { ?>
103
  } else {
104
  $author_name .= ' &nbsp; (' . __('shared', 'grand-media') . ')';
105
  }
106
+ if('publish' != $term->status) {
107
  $author_name .= ' [' . $term->status . ']';
108
  }
109
 
159
  <div class="form-group status-item bg-status-<?php echo $item->status; ?>">
160
  <label><?php _e('Status', 'grand-media'); ?></label>
161
  <select name="status" class="form-control input-sm">
162
+ <option <?php selected($item->status, 'publish'); ?> value="publish"><?php _e('Public', 'grand-media'); ?></option>
163
  <option <?php selected($item->status, 'private'); ?> value="private"><?php _e('Private', 'grand-media'); ?></option>
164
  <option <?php selected($item->status, 'draft'); ?> value="draft"><?php _e('Draft', 'grand-media'); ?></option>
165
  </select>
166
  </div>
167
+ <?php if(!empty($item->post_id)){ ?>
168
+ <div class="form-group">
169
+ <a href="<?php echo admin_url("admin.php?page=GrandMedia&gmediablank=comments&gmedia_id={$item->ID}"); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count pull-right" title="<?php esc_attr_e('Comments', 'grand-media'); ?>">
170
+ <b class="comment-count"><?php echo $item->comment_count; ?></b>
171
+ <span class="glyphicon glyphicon-comment"></span>
172
+ </a>
173
+ <label><?php _e('Comment Status', 'grand-media'); ?></label>
174
+ <select name="comment_status" class="form-control input-sm">
175
+ <option <?php selected($item->comment_status, 'open'); ?> value="open"><?php _e('Open', 'grand-media'); ?></option>
176
+ <option <?php selected($item->comment_status, 'closed'); ?> value="closed"><?php _e('Closed', 'grand-media'); ?></option>
177
+ </select>
178
+ </div>
179
+ <?php } ?>
180
  </div>
181
  <div class="col-lg-6">
182
  <div class="form-group">
206
 
207
  <div class="input-group input-group-sm">
208
  <input name="meta[_gps]" type="text" class="form-control input-sm gps_map_coordinates" value="<?php echo $item->gps; ?>" placeholder="<?php _e('Latitude, Longtitude', 'grand-media'); ?>" autocomplete="off"/>
209
+ <span class="input-group-btn"><a href="<?php echo admin_url("admin.php?page=GrandMedia&gmediablank=map_editor&id={$item->ID}"); ?>" class="btn btn-primary gmedit-modal" data-target="#gmeditModal">
210
  <span class="glyphicon glyphicon-map-marker"></span></a></span>
211
  </div>
212
  </div>
admin/{library → pages/library}/tpl/grid-item.php RENAMED
@@ -3,14 +3,15 @@
3
  * Gmedia Item for Grid View in Library
4
  */
5
  ?>
6
- <div class="cb_list-item gm-item-cell col-xs-6 col-sm-4 col-md-3 col-lg-2<?php echo ($item->selected? ' gm-selected ' : ' ') . implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>">
7
  <div class="thumbnail <?php echo ($item->thumb_ratio >= 1)? 'landscape' : 'portrait'; ?>">
8
  <label class="cb_media-object">
9
  <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" class="hidden" value="<?php echo $item->ID; ?>"/>
10
- <span data-target="<?php echo $item->url; ?>" class="centered">
11
- <?php gmedia_item_thumbnail($item); ?>
12
- </span>
13
  </label>
 
14
  <div class="gm-cell-more">
15
  <span class="gm-cell-more-btn glyphicon glyphicon-option-vertical"></span>
16
  <div class="gm-cell-title"><span><?php echo esc_html($item->title); ?>&nbsp;</span></div>
@@ -63,6 +64,13 @@
63
  echo $terms_tag;
64
  ?>
65
 
 
 
 
 
 
 
 
66
  <br/><span class="label label-default"><?php _e('Views / Likes', 'grand-media'); ?>:</span>
67
  <?php echo (isset($item->meta['views'][0])? $item->meta['views'][0] : '0') . ' / ' . (isset($item->meta['likes'][0])? $item->meta['likes'][0] : '0'); ?>
68
 
3
  * Gmedia Item for Grid View in Library
4
  */
5
  ?>
6
+ <div class="cb_list-item gm-item-cell col-xs-6 col-sm-4 col-md-3 col-lg-2 <?php echo implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>">
7
  <div class="thumbnail <?php echo ($item->thumb_ratio >= 1)? 'landscape' : 'portrait'; ?>">
8
  <label class="cb_media-object">
9
  <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" class="hidden" value="<?php echo $item->ID; ?>"/>
10
+ <span data-target="<?php echo $item->url; ?>" class="centered">
11
+ <?php gmedia_item_thumbnail($item); ?>
12
+ </span>
13
  </label>
14
+ <label class="gm-stack"><input title="<?php _e('Add to Stack', 'grand-media'); ?>" name="stack[]" type="checkbox"<?php echo $item->in_stack? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/></label>
15
  <div class="gm-cell-more">
16
  <span class="gm-cell-more-btn glyphicon glyphicon-option-vertical"></span>
17
  <div class="gm-cell-title"><span><?php echo esc_html($item->title); ?>&nbsp;</span></div>
64
  echo $terms_tag;
65
  ?>
66
 
67
+ <?php if(isset($item->post_id)) { ?>
68
+ <br/><span class="label label-default"><?php _e('Comments', 'grand-media'); ?>:</span>
69
+ <a href="<?php echo admin_url("admin.php?page=GrandMedia&gmediablank=comments&gmedia_id={$item->ID}"); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count" title="<?php esc_attr_e('Comments', 'grand-media'); ?>">
70
+ <b class="comment-count"><?php echo $item->comment_count; ?></b>
71
+ <span class="glyphicon glyphicon-comment"></span>
72
+ </a>
73
+ <?php } ?>
74
  <br/><span class="label label-default"><?php _e('Views / Likes', 'grand-media'); ?>:</span>
75
  <?php echo (isset($item->meta['views'][0])? $item->meta['views'][0] : '0') . ' / ' . (isset($item->meta['likes'][0])? $item->meta['likes'][0] : '0'); ?>
76
 
admin/{library → pages/library}/tpl/list-item.php RENAMED
@@ -6,15 +6,19 @@
6
  * @var $item
7
  */
8
  ?>
9
- <div class="cb_list-item list-group-item d-row clearfix<?php echo ($item->selected? ' gm-selected ' : ' ') . implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>">
10
  <div class="gmedia_id">#<?php echo $item->ID; ?></div>
11
- <label class="cb_media-object col-sm-4" style="max-width:340px;">
12
- <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" class="hidden" value="<?php echo $item->ID; ?>"/>
13
- <span data-target="<?php echo $item->url; ?>" class="thumbnail">
14
- <?php gmedia_item_thumbnail($item); ?>
15
- </span>
16
- </label>
17
-
 
 
 
 
18
  <div class="col-sm-8">
19
  <div class="row" style="margin:0;">
20
  <div class="col-lg-6">
@@ -73,6 +77,15 @@
73
  echo implode(' | ', $media_action_links);
74
  ?>
75
  </div>
 
 
 
 
 
 
 
 
 
76
  <p class="media-meta">
77
  <span class="label label-default"><?php _e('Views / Likes', 'grand-media'); ?>:</span>
78
  <?php echo (isset($item->meta['views'][0])? $item->meta['views'][0] : '0') . ' / ' . (isset($item->meta['likes'][0])? $item->meta['likes'][0] : '0'); ?>
6
  * @var $item
7
  */
8
  ?>
9
+ <div class="cb_list-item list-group-item d-row clearfix <?php echo implode(' ', $item->classes); ?>" id="list-item-<?php echo $item->ID; ?>" data-id="<?php echo $item->ID; ?>" data-type="<?php echo $item->type; ?>">
10
  <div class="gmedia_id">#<?php echo $item->ID; ?></div>
11
+ <div class="col-sm-4" style="max-width:340px;">
12
+ <div class="thumbwrap">
13
+ <label class="cb_media-object">
14
+ <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" class="hidden" value="<?php echo $item->ID; ?>"/>
15
+ <span data-target="<?php echo $item->url; ?>" class="thumbnail">
16
+ <?php gmedia_item_thumbnail($item); ?>
17
+ </span>
18
+ </label>
19
+ <label class="gm-stack"><input title="<?php _e('Add to Stack', 'grand-media'); ?>" name="stack[]" type="checkbox"<?php echo $item->in_stack? ' checked="checked"' : ''; ?> data-type="<?php echo $item->type; ?>" value="<?php echo $item->ID; ?>"/></label>
20
+ </div>
21
+ </div>
22
  <div class="col-sm-8">
23
  <div class="row" style="margin:0;">
24
  <div class="col-lg-6">
77
  echo implode(' | ', $media_action_links);
78
  ?>
79
  </div>
80
+ <?php if(isset($item->post_id)) { ?>
81
+ <p class="media-meta">
82
+ <span class="label label-default"><?php _e('Comments', 'grand-media'); ?>:</span>
83
+ <a href="<?php echo admin_url("admin.php?page=GrandMedia&gmediablank=comments&gmedia_id={$item->ID}"); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count" title="<?php esc_attr_e('Comments', 'grand-media'); ?>">
84
+ <b class="comment-count"><?php echo $item->comment_count; ?></b>
85
+ <span class="glyphicon glyphicon-comment"></span>
86
+ </a>
87
+ </p>
88
+ <?php } ?>
89
  <p class="media-meta">
90
  <span class="label label-default"><?php _e('Views / Likes', 'grand-media'); ?>:</span>
91
  <?php echo (isset($item->meta['views'][0])? $item->meta['views'][0] : '0') . ' / ' . (isset($item->meta['likes'][0])? $item->meta['likes'][0] : '0'); ?>
admin/{library/tpl/no-item.php → pages/library/tpl/no-items.php} RENAMED
File without changes
admin/{library → pages/library}/tpl/panel-footer.php RENAMED
File without changes
admin/{library → pages/library}/tpl/panel-heading.php RENAMED
@@ -6,29 +6,27 @@
6
  ?>
7
  <div class="panel-heading-fake"></div>
8
  <div class="panel-heading clearfix" style="padding-bottom:2px;">
9
- <div class="pull-right" style="margin-bottom:7px;">
10
  <div class="clearfix">
11
- <?php
12
-
13
- include(GMEDIA_ABSPATH . 'admin/tpl/search-form.php');
14
 
15
- echo $gmedia_pager;
 
16
 
17
- ?>
18
- </div>
19
- <div class="btn-toolbar pull-right">
20
- <a class="show-settings-link pull-right btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></a>
21
-
22
- <?php if(!$gmProcessor->edit_mode) { ?>
23
- <div class="btn-group pull-right">
24
- <a href="<?php echo gm_get_admin_url(array('display_mode' => 'grid')); ?>" class="btn btn<?php echo ($gmedia_user_options['display_mode_gmedia'] == 'grid')? '-primary active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-th"></span> <?php _e('Show as Grid', 'grand-media'); ?></a>
25
- <a href="<?php echo gm_get_admin_url(array('display_mode' => 'list')); ?>" class="btn btn<?php echo ($gmedia_user_options['display_mode_gmedia'] == 'list')? '-primary active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-th-list"></span> <?php _e('Show as List', 'grand-media'); ?></a>
26
- </div>
27
- <?php if($gmedia_user_options['display_mode_gmedia'] == 'grid') { ?>
28
- <a href="<?php echo gm_get_admin_url(array('grid_cell_fit' => 'toggle')); ?>" class="fit-thumbs pull-right btn btn<?php echo ($gmedia_user_options['grid_cell_fit_gmedia'] == 'true')? '-success active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-eye-open"></span></a>
29
  <?php } ?>
30
- <?php } ?>
31
  </div>
 
 
 
32
  </div>
33
  <div class="btn-toolbar pull-left" style="margin-bottom:7px;">
34
  <div class="btn-group gm-checkgroup" id="cb_global-btn">
@@ -132,9 +130,6 @@
132
  <a href="#libModal" data-modal="batch_edit" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Batch Edit', 'grand-media'); ?></a></li>
133
 
134
  <li class="divider"></li>
135
- <li class="<?php echo $rel_selected_show . (gm_user_can('gallery_manage')? '' : ' disabled'); ?>">
136
- <a href="#libModal" data-modal="quick_gallery" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Quick Gallery from Selected', 'grand-media'); ?></a>
137
- </li>
138
  <li class="<?php echo $rel_selected_show . (gm_user_can('terms')? '' : ' disabled'); ?>">
139
  <a href="#libModal" data-modal="assign_category" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Assign Category...', 'grand-media'); ?></a>
140
  </li>
@@ -161,10 +156,33 @@
161
  </div>
162
 
163
  <?php
 
 
 
164
  $filter_selected = $gmCore->_req('filter');
165
  $filter_selected_arg = $filter_selected? false : 'selected';
166
  ?>
167
- <form class="btn-group" id="gm-selected-btn" name="gm-selected-form" action="<?php echo add_query_arg(array('filter' => $filter_selected_arg), $gmedia_url); ?>" method="post">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  <button type="submit" class="btn btn<?php echo ('selected' == $filter_selected)? '-success' : '-info' ?>"><?php printf(__('%s selected', 'grand-media'), '<span id="gm-selected-qty">' . count($gmProcessor->selected_items) . '</span>'); ?></button>
169
  <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
170
  <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
@@ -178,6 +196,8 @@
178
  }
179
  ?></a></li>
180
  <li><a id="gm-selected-clear" href="#clear"><?php _e('Clear selected items', 'grand-media'); ?></a></li>
 
 
181
  <li class="<?php echo gm_user_can('gallery_manage')? '' : 'disabled'; ?>">
182
  <a href="#libModal" data-modal="quick_gallery" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Quick Gallery from Selected', 'grand-media'); ?></a>
183
  </li>
6
  ?>
7
  <div class="panel-heading-fake"></div>
8
  <div class="panel-heading clearfix" style="padding-bottom:2px;">
9
+ <div class="pull-right" style="margin-bottom:3px;">
10
  <div class="clearfix">
11
+ <?php include(GMEDIA_ABSPATH . 'admin/tpl/search-form.php'); ?>
 
 
12
 
13
+ <div class="btn-toolbar pull-right" style="margin-bottom:4px; margin-left:4px;">
14
+ <a title="<?php _e('More Screen Settings', 'grand-media'); ?>" class="show-settings-link pull-right btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></a>
15
 
16
+ <?php if(!$gmProcessor->edit_mode) { ?>
17
+ <div class="btn-group pull-right">
18
+ <a title="<?php _e('Show as Grid', 'grand-media'); ?>" href="<?php echo gm_get_admin_url(array('display_mode' => 'grid')); ?>" class="btn btn<?php echo ($gmedia_user_options['display_mode_gmedia'] == 'grid')? '-primary active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-th"></span></a>
19
+ <a title="<?php _e('Show as List', 'grand-media'); ?>" href="<?php echo gm_get_admin_url(array('display_mode' => 'list')); ?>" class="btn btn<?php echo ($gmedia_user_options['display_mode_gmedia'] == 'list')? '-primary active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-th-list"></span></a>
20
+ </div>
21
+ <?php if($gmedia_user_options['display_mode_gmedia'] == 'grid') { ?>
22
+ <a title="<?php _e('Thumbnails Fit/Fill Cell', 'grand-media'); ?>" href="<?php echo gm_get_admin_url(array('grid_cell_fit' => 'toggle')); ?>" class="fit-thumbs pull-right btn btn<?php echo ($gmedia_user_options['grid_cell_fit_gmedia'] == 'true')? '-success active' : '-default'; ?> btn-xs"><span class="glyphicon glyphicon-eye-open"></span></a>
23
+ <?php } ?>
 
 
 
 
24
  <?php } ?>
25
+ </div>
26
  </div>
27
+
28
+ <?php echo $gmedia_pager; ?>
29
+
30
  </div>
31
  <div class="btn-toolbar pull-left" style="margin-bottom:7px;">
32
  <div class="btn-group gm-checkgroup" id="cb_global-btn">
130
  <a href="#libModal" data-modal="batch_edit" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Batch Edit', 'grand-media'); ?></a></li>
131
 
132
  <li class="divider"></li>
 
 
 
133
  <li class="<?php echo $rel_selected_show . (gm_user_can('terms')? '' : ' disabled'); ?>">
134
  <a href="#libModal" data-modal="assign_category" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Assign Category...', 'grand-media'); ?></a>
135
  </li>
156
  </div>
157
 
158
  <?php
159
+ $filter_stack = $gmCore->_req('stack');
160
+ $filter_stack_arg = $filter_stack? false : 'show';
161
+
162
  $filter_selected = $gmCore->_req('filter');
163
  $filter_selected_arg = $filter_selected? false : 'selected';
164
  ?>
165
+ <form class="btn-group" id="gm-stack-btn" name="gm-stack-form" action="<?php echo add_query_arg(array('stack' => $filter_stack_arg, 'filter' => $filter_selected), $gmedia_url); ?>" method="post">
166
+ <button type="submit" class="btn btn<?php echo ('show' == $filter_stack)? '-success' : '-info' ?>"><?php printf(__('%s in Stack', 'grand-media'), '<span id="gm-stack-qty">' . count($gmProcessor->stack_items) . '</span>'); ?></button>
167
+ <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
168
+ <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
169
+ <input type="hidden" id="gm-stack" data-userid="<?php echo $user_ID; ?>" data-key="library_stack" name="stack_items" value="<?php echo implode(',', $gmProcessor->stack_items); ?>"/>
170
+ <ul class="dropdown-menu" role="menu">
171
+ <li><a id="gm-stack-show" href="#show"><?php
172
+ if(!$filter_stack) {
173
+ _e('Show Stack', 'grand-media');
174
+ } else {
175
+ _e('Show Library', 'grand-media');
176
+ }
177
+ ?></a></li>
178
+ <li><a id="gm-stack-clear" href="#clear"><?php _e('Clear Stack', 'grand-media'); ?></a></li>
179
+ <li class="<?php echo gm_user_can('gallery_manage')? '' : 'disabled'; ?>">
180
+ <a href="#libModal" data-modal="quick_gallery_stack" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Quick Gallery from Stack', 'grand-media'); ?></a>
181
+ </li>
182
+ </ul>
183
+ </form>
184
+
185
+ <form class="btn-group" id="gm-selected-btn" name="gm-selected-form" action="<?php echo add_query_arg(array('stack' => $filter_stack, 'filter' => $filter_selected_arg), $gmedia_url); ?>" method="post">
186
  <button type="submit" class="btn btn<?php echo ('selected' == $filter_selected)? '-success' : '-info' ?>"><?php printf(__('%s selected', 'grand-media'), '<span id="gm-selected-qty">' . count($gmProcessor->selected_items) . '</span>'); ?></button>
187
  <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
188
  <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
196
  }
197
  ?></a></li>
198
  <li><a id="gm-selected-clear" href="#clear"><?php _e('Clear selected items', 'grand-media'); ?></a></li>
199
+ <li><a id="gm-stack-in" href="#stack_add"><?php _e('Add selected items to Stack', 'grand-media'); ?></a></li>
200
+ <li><a id="gm-stack-out" href="#stack_remove"><?php _e('Remove selected items from Stack', 'grand-media'); ?></a></li>
201
  <li class="<?php echo gm_user_can('gallery_manage')? '' : 'disabled'; ?>">
202
  <a href="#libModal" data-modal="quick_gallery" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Quick Gallery from Selected', 'grand-media'); ?></a>
203
  </li>
admin/pages/modules/functions.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Modules functions
4
+ */
5
+
6
+ function gmedia_get_modules() {
7
+ global $gmCore, $gmGallery;
8
+
9
+ $modules = array();
10
+ $modules['in'] = array(
11
+ 'phantom' => ''
12
+ , 'phototravlr' => ''
13
+ , 'realslider' => ''
14
+ , 'mosaic' => ''
15
+ , 'photobox' => ''
16
+ , 'photomania' => ''
17
+ , 'jq-mplayer' => ''
18
+ , 'wp-videoplayer' => ''
19
+ , 'photo-pro' => ''
20
+ , 'optima' => ''
21
+ , 'afflux' => ''
22
+ , 'slider' => ''
23
+ , 'green-style' => ''
24
+ , 'photo-blog' => ''
25
+ , 'minima' => ''
26
+ , 'sphere' => ''
27
+ , 'cube' => ''
28
+ , 'flatwall' => ''
29
+ );
30
+ if(($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
31
+ foreach($plugin_modules as $path) {
32
+ $mfold = basename($path);
33
+ $modules['in'][$mfold] = array(
34
+ 'place' => 'plugin',
35
+ 'module_name' => $mfold,
36
+ 'module_url' => $gmCore->gmedia_url . "/module/{$mfold}",
37
+ 'module_path' => $path
38
+ );
39
+ }
40
+ }
41
+ if(($upload_modules = glob($gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
42
+ foreach($upload_modules as $path) {
43
+ $mfold = basename($path);
44
+ $modules['in'][$mfold] = array(
45
+ 'place' => 'upload',
46
+ 'module_name' => $mfold,
47
+ 'module_url' => $gmCore->upload['url'] . "/{$gmGallery->options['folder']['module']}/{$mfold}",
48
+ 'module_path' => $path
49
+ );
50
+ }
51
+ }
52
+
53
+ $modules['in'] = array_filter($modules['in']);
54
+
55
+ if(isset($modules['in']) && !empty($modules['in'])) {
56
+ foreach($modules['in'] as $mfold => $module) {
57
+ // todo: get broken modules folders and delete them
58
+ if(!file_exists($module['module_path'] . '/index.php')) {
59
+ unset($modules['in'][$mfold]);
60
+ continue;
61
+ }
62
+ $module_info = array();
63
+ include($module['module_path'] . '/index.php');
64
+ if(empty($module_info)) {
65
+ unset($modules['in'][$mfold]);
66
+ continue;
67
+ }
68
+ $modules['in'][$mfold] = array_merge($module, (array)$module_info);
69
+ $modules['in'][$mfold]['update'] = false;
70
+ }
71
+ }
72
+
73
+ $get_xml = wp_remote_get($gmGallery->options['modules_xml'], array('sslverify' => true));
74
+ if(!is_wp_error($get_xml) && (200 == $get_xml['response']['code'])) {
75
+ $xml = @simplexml_load_string($get_xml['body']);
76
+ if(!empty($xml)) {
77
+ foreach($xml as $m) {
78
+ $name = (string)$m->name;
79
+ $modules['xml'][$name] = get_object_vars($m);
80
+ $modules['xml'][$name]['place'] = 'remote';
81
+ if(isset($modules['in'][$name]) && !empty($modules['in'][$name])) {
82
+ $modules['in'][$name] = array_merge(get_object_vars($m), $modules['in'][$name]);
83
+ if(version_compare((float)$modules['xml'][$name]['version'], (float)$modules['in'][$name]['version'], '>')) {
84
+ $modules['in'][$name]['update'] = $modules['xml'][$name]['version'];
85
+ $modules['out'][$name] = $modules['xml'][$name];
86
+ }
87
+ } else {
88
+ $modules['out'][$name] = $modules['xml'][$name];
89
+ }
90
+ }
91
+ }
92
+ } else {
93
+ $modules['error'] = array(__('Error loading remote xml...', 'grand-media'));
94
+ if(is_wp_error($get_xml)) {
95
+ $modules['error'][] = $get_xml->get_error_message();
96
+ }
97
+ }
98
+
99
+ return $modules;
100
+ }
101
+
102
+ function gmedia_module_action_buttons($module) {
103
+ global $gmCore, $gmProcessor;
104
+
105
+ $buttons = array();
106
+ if('remote' == $module['place']) {
107
+ $buttons['install'] = '<a class="btn btn-primary ' . (gm_user_can('module_manage')? 'module_install' : 'disabled') . '" data-module="' . $module['name'] . '" data-loading-text="' . __('Loading...', 'grand-media') . '" href="' . esc_url($module['download']) . '">' . __('Install Module', 'grand-media') . '</a>';
108
+ } else {
109
+ $buttons['create'] = '<a class="btn btn-success" href="' . $gmCore->get_admin_url(array('page' => 'GrandMedia_Galleries', 'gallery_module' => $module['module_name']), array(), true) . '">' . __('Create Gallery', 'grand-media') . '</a>';
110
+ }
111
+ if(!empty($module['demo']) && $module['demo'] != '#') {
112
+ $buttons['demo'] = '<a class="btn btn-default" target="_blank" href="' . $module['demo'] . '">' . __('View Demo', 'grand-media') . '</a>';
113
+ }
114
+ if(!empty($module['update']) && 'remote' != $module['place']) {
115
+ $buttons['update'] = '<a class="btn btn-warning module_install" data-module="' . $module['module_name'] . '" data-loading-text="' . __('Loading...', 'grand-media') . '" href="' . esc_url($module['download']) . '">' . __('Update Module', 'grand-media') . " (v{$module['update']})</a>";
116
+ }
117
+ if(('upload' == $module['place']) && gm_user_can('module_manage')) {
118
+ $buttons['delete'] = '<a class="btn btn-danger" href="' . wp_nonce_url($gmCore->get_admin_url(array('delete_module' => $module['module_name']), array(), $gmProcessor->url), 'gmedia_module_delete') . '">' . __('Delete Module', 'grand-media') . '</a>';
119
+ }
120
+ if(!empty($module['download'])) {
121
+ $buttons['download'] = '<a class="btn btn-link" href="' . $module['download'] . '" download="true">' . __('Download module ZIP', 'grand-media') . '</a>';
122
+ }
123
+
124
+ return $buttons;
125
+ }
admin/pages/modules/modules.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Gmedia Modules
4
+ */
5
+
6
+ // don't load directly
7
+ if(!defined('ABSPATH')) {
8
+ die('-1');
9
+ }
10
+
11
+ global $gmCore, $gmProcessor, $gmGallery;
12
+
13
+ $gmedia_url = $gmProcessor->url;
14
+ $modules = gmedia_get_modules();
15
+
16
+ if(isset($modules['error'])) {
17
+ echo $gmCore->alert('danger', $modules['error']);
18
+ }
19
+
20
+ ?>
21
+ <div id="gmedia_modules">
22
+ <div class="panel panel-default">
23
+ <div class="panel-heading clearfix">
24
+ <a href="#installModuleModal" class="btn btn-primary pull-right<?php echo current_user_can('manage_options')? '' : ' disabled'; ?>" data-toggle="modal"><?php _e('Install Module ZIP'); ?></a>
25
+
26
+ <h3 class="panel-title"><?php _e('Installed Modules', 'grand-media'); ?></h3>
27
+ </div>
28
+ <div class="panel-body" id="gmedia-msg-panel"></div>
29
+ <div class="panel-body">
30
+ <?php
31
+ // installed modules
32
+ if(!empty($modules['in'])) {
33
+ foreach($modules['in'] as $module) {
34
+ $module['screenshot_url'] = $module['module_url'] . '/screenshot.png';
35
+ $module['mclass'] = ' module-' . $module['type'] . ' module-' . $module['status'];
36
+ if($module['update']) {
37
+ $module['mclass'] .= ' module-update';
38
+ }
39
+
40
+ include(dirname(__FILE__) . '/tpl/module-item.php');
41
+
42
+ }
43
+ }
44
+ ?>
45
+ </div>
46
+ </div>
47
+
48
+ <?php if(!empty($modules['out'])) { ?>
49
+ <div class="panel panel-default">
50
+ <div class="panel-heading clearfix">
51
+ <h3 class="panel-title"><?php _e('Not Installed Modules', 'grand-media'); ?></h3>
52
+ </div>
53
+ <div class="panel-body" id="gmedia-msg-panel"></div>
54
+ <div class="panel-body">
55
+ <?php
56
+ $out_dirpath = dirname($gmGallery->options['modules_xml']);
57
+ foreach($modules['out'] as $module) {
58
+ $module['mclass'] = ' module-' . $module['type'] . ' module-' . $module['status'];
59
+ $module['screenshot_url'] = $out_dirpath . '/' . $module['name'] . '.png';
60
+
61
+ include(dirname(__FILE__) . '/tpl/module-item.php');
62
+
63
+ } ?>
64
+ </div>
65
+ </div>
66
+ <?php } ?>
67
+ </div>
68
+
69
+ <?php if($gmCore->caps['gmedia_module_manage']) {
70
+ include(dirname(__FILE__) . '/tpl/modal-modulezip.php');
71
+ } ?>
72
+
admin/pages/modules/tpl/modal-modulezip.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Modal to install Module ZIP
4
+ */
5
+ ?>
6
+ <div class="modal fade gmedia-modal" id="installModuleModal" tabindex="-1" role="dialog" aria-hidden="true">
7
+ <div class="modal-dialog">
8
+ <form class="modal-content" method="post" enctype="multipart/form-data" action="<?php echo $gmedia_url; ?>">
9
+ <div class="modal-header">
10
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
11
+ <h4 class="modal-title"><?php _e('Install a plugin in .zip format'); ?></h4>
12
+ </div>
13
+ <div class="modal-body">
14
+ <p class="install-help"><?php _e('If you have a module in a .zip format, you may install it by uploading it here.'); ?></p>
15
+ <?php wp_nonce_field('GmediaModule'); ?>
16
+ <label class="screen-reader-text" for="modulezip"><?php _e('Module zip file'); ?></label>
17
+ <input type="file" id="modulezip" name="modulezip"/>
18
+ </div>
19
+ <div class="modal-footer">
20
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Cancel', 'grand-media'); ?></button>
21
+ <button type="submit" class="btn btn-primary"><?php _e('Install', 'grand-media'); ?></button>
22
+ </div>
23
+ </form>
24
+ </div>
25
+ </div>
26
+
admin/pages/modules/tpl/module-item.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Module List Item
4
+ */
5
+ ?>
6
+ <div class="media<?php echo $module['mclass']; ?>">
7
+ <div class="thumbnail pull-left">
8
+ <img class="media-object" src="<?php echo $module['screenshot_url']; ?>" alt="<?php echo esc_attr($module['title']); ?>" width="320" height="240"/>
9
+ </div>
10
+ <div class="media-body" style="margin-left:340px;">
11
+ <h4 class="media-heading"><?php echo $module['title']; ?></h4>
12
+
13
+ <p class="version"><?php echo __('Version', 'grand-media') . ': ' . $module['version']; ?></p>
14
+ <?php if(isset($module['info'])) { ?>
15
+ <div class="module_info"><?php echo str_replace("\n", '<br />', (string)$module['info']); ?></div>
16
+ <?php } ?>
17
+ <div class="description"><?php echo str_replace("\n", '<br />', (string)$module['description']); ?></div>
18
+ <hr/>
19
+ <p class="buttons">
20
+ <?php
21
+ $buttons = gmedia_module_action_buttons($module);
22
+ echo implode(' ', $buttons);
23
+ ?>
24
+ </p>
25
+ </div>
26
+ </div>
admin/pages/settings/settings.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Gmedia Settings
4
+ */
5
+
6
+ // don't load directly
7
+ if(!defined('ABSPATH')) {
8
+ die('-1');
9
+ }
10
+
11
+
12
+ global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
13
+
14
+ $url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
15
+ $lk = isset($gmGallery->options['license_key'])? $gmGallery->options['license_key'] : '';
16
+ ?>
17
+
18
+ <form id="gmediaSettingsForm" class="panel panel-default" method="post" action="<?php echo $url; ?>">
19
+ <div class="panel-heading clearfix">
20
+ <div class="btn-toolbar pull-left">
21
+ <div class="btn-group">
22
+ <button type="submit" name="gmedia_settings_reset" class="btn btn-default" data-confirm="<?php _e('Reset all Gmedia settings?', 'grand-media') ?>"><?php _e('Reset Settings', 'grand-media'); ?></button>
23
+ <button type="submit" name="gmedia_settings_save" class="btn btn-primary"><?php _e('Update', 'grand-media'); ?></button>
24
+ </div>
25
+ </div>
26
+ <?php
27
+ wp_nonce_field('GmediaSettings');
28
+ ?>
29
+ </div>
30
+ <div class="panel-body" id="gmedia-msg-panel"></div>
31
+ <div class="container-fluid">
32
+ <div class="tabable tabs-left">
33
+ <ul id="settingsTabs" class="nav nav-tabs" style="padding:10px 0;">
34
+ <li class="active"><a href="#gmedia_premium" data-toggle="tab"><?php _e('Premium Settings', 'grand-media'); ?></a></li>
35
+ <li><a href="#gmedia_settings_other" data-toggle="tab"><?php _e('Other Settings', 'grand-media'); ?></a></li>
36
+ <?php if(current_user_can('manage_options')) { ?>
37
+ <li><a href="#gmedia_settings_permalinks" data-toggle="tab"><?php _e('Permalinks', 'grand-media'); ?></a></li>
38
+ <li><a href="#gmedia_settings_cloud" data-toggle="tab"><?php _e('GmediaCloud Page', 'grand-media'); ?></a></li>
39
+ <li><a href="#gmedia_settings_roles" data-toggle="tab"><?php _e('Roles/Capabilities Manager', 'grand-media'); ?></a></li>
40
+ <?php } ?>
41
+ <li><a href="#gmedia_settings_sysinfo" data-toggle="tab"><?php _e('System Info', 'grand-media'); ?></a></li>
42
+ </ul>
43
+ <div class="tab-content" style="padding-top:21px;">
44
+ <?php
45
+ include(dirname(__FILE__) . '/tpl/license.php');
46
+ include(dirname(__FILE__) . '/tpl/common.php');
47
+ if(current_user_can('manage_options')) {
48
+ include(dirname(__FILE__) . '/tpl/permalinks.php');
49
+ include(dirname(__FILE__) . '/tpl/roles.php');
50
+ }
51
+ include(dirname(__FILE__) . '/tpl/system.php');
52
+ ?>
53
+
54
+ </div>
55
+ <div class="clear"></div>
56
+ </div>
57
+ <script type="text/javascript">
58
+ jQuery(function($) {
59
+ var hash = window.location.hash;
60
+ if(hash) {
61
+ hash = hash.replace('_tab', '');
62
+ $('#settingsTabs a[href="' + hash + '"]').tab('show');
63
+ }
64
+ $('#gmediaSettingsForm').on('submit', function() {
65
+ $(this).attr('action', $(this).attr('action') + $('#settingsTabs li.active a').attr('href') + '_tab');
66
+ });
67
+ });
68
+ </script>
69
+ </div>
70
+ </form>
admin/pages/settings/tpl/common.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Common Settings
4
+ *
5
+ * @var $gmGallery
6
+ */
7
+ ?>
8
+ <fieldset id="gmedia_settings_other" class="tab-pane">
9
+ <div class="form-group">
10
+ <label><?php _e('When delete (uninstall) plugin', 'grand-media') ?>:</label>
11
+ <select name="set[uninstall_dropdata]" class="form-control input-sm">
12
+ <option value="all" <?php selected($gmGallery->options['uninstall_dropdata'], 'all'); ?>><?php _e('Delete database and all uploaded files', 'grand-media'); ?></option>
13
+ <option value="db" <?php selected($gmGallery->options['uninstall_dropdata'], 'db'); ?>><?php _e('Delete database only and leave uploaded files', 'grand-media'); ?></option>
14
+ <option value="none" <?php selected($gmGallery->options['uninstall_dropdata'], 'none'); ?>><?php _e('Do not delete database and uploaded files', 'grand-media'); ?></option>
15
+ </select>
16
+ </div>
17
+ <div class="form-group row">
18
+ <div class="col-xs-6">
19
+ <label><?php _e('In Tags order gmedia', 'grand-media'); ?></label>
20
+ <select name="set[in_tag_orderby]" class="form-control input-sm">
21
+ <option value="ID" <?php selected($gmGallery->options['in_tag_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
22
+ <option value="title" <?php selected($gmGallery->options['in_tag_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
23
+ <option value="gmuid" <?php selected($gmGallery->options['in_tag_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
24
+ <option value="date" <?php selected($gmGallery->options['in_tag_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
25
+ <option value="modified" <?php selected($gmGallery->options['in_tag_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
26
+ <option value="rand" <?php selected($gmGallery->options['in_tag_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
27
+ </select>
28
+ </div>
29
+ <div class="col-xs-6">
30
+ <label><?php _e('Sort order', 'grand-media'); ?></label>
31
+ <select name="set[in_tag_order]" class="form-control input-sm">
32
+ <option value="DESC" <?php selected($gmGallery->options['in_tag_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
33
+ <option value="ASC" <?php selected($gmGallery->options['in_tag_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
34
+ </select>
35
+ </div>
36
+ </div>
37
+ <div class="form-group row">
38
+ <div class="col-xs-6">
39
+ <label><?php _e('In Category order gmedia', 'grand-media'); ?></label>
40
+ <select name="set[in_category_orderby]" class="form-control input-sm">
41
+ <option value="ID" <?php selected($gmGallery->options['in_category_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
42
+ <option value="title" <?php selected($gmGallery->options['in_category_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
43
+ <option value="gmuid" <?php selected($gmGallery->options['in_category_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
44
+ <option value="date" <?php selected($gmGallery->options['in_category_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
45
+ <option value="modified" <?php selected($gmGallery->options['in_category_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
46
+ <option value="rand" <?php selected($gmGallery->options['in_category_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
47
+ </select>
48
+ </div>
49
+ <div class="col-xs-6">
50
+ <label><?php _e('Sort order', 'grand-media'); ?></label>
51
+ <select name="set[in_category_order]" class="form-control input-sm">
52
+ <option value="DESC" <?php selected($gmGallery->options['in_category_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
53
+ <option value="ASC" <?php selected($gmGallery->options['in_category_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
54
+ </select>
55
+ </div>
56
+ </div>
57
+ <div class="form-group">
58
+ <label><?php _e('Forbid other plugins to load their JS and CSS on Gmedia admin pages', 'grand-media') ?>:</label>
59
+
60
+ <div class="checkbox" style="margin:0;">
61
+ <input type="hidden" name="set[isolation_mode]" value="0"/>
62
+ <label><input type="checkbox" name="set[isolation_mode]" value="1" <?php checked($gmGallery->options['isolation_mode'], '1'); ?> /> <?php _e('Enable Gmedia admin panel Isolation Mode', 'grand-media'); ?> </label>
63
+
64
+ <p class="help-block"><?php _e('This option could help to avoid JS and CSS conflicts with other plugins in admin panel.', 'grand-media'); ?></p>
65
+ </div>
66
+ </div>
67
+ <div class="form-group">
68
+ <label><?php _e('Forbid theme to format Gmedia shortcode\'s content', 'grand-media') ?>:</label>
69
+
70
+ <div class="checkbox" style="margin:0;">
71
+ <input type="hidden" name="set[shortcode_raw]" value="0"/>
72
+ <label><input type="checkbox" name="set[shortcode_raw]" value="1" <?php checked($gmGallery->options['shortcode_raw'], '1'); ?> /> <?php _e('Raw output for Gmedia Shortcode', 'grand-media'); ?> </label>
73
+
74
+ <p class="help-block"><?php _e('Some themes reformat shortcodes and break it functionality (mostly when you add description to images). Turning this on should solve this problem.', 'grand-media'); ?></p>
75
+ </div>
76
+ </div>
77
+ <div class="form-group">
78
+ <label><?php _e('Debug Mode', 'grand-media') ?>:</label>
79
+
80
+ <div class="checkbox" style="margin:0;">
81
+ <input type="hidden" name="set[debug_mode]" value=""/>
82
+ <label><input type="checkbox" name="set[debug_mode]" value="1" <?php checked($gmGallery->options['debug_mode'], '1'); ?> /> <?php _e('Enable Debug Mode on Gmedia admin pages', 'grand-media'); ?> </label>
83
+ </div>
84
+ </div>
85
+ <?php
86
+ $allowed_post_types = (array)$gmGallery->options['gmedia_post_types_support'];
87
+ $args = array(
88
+ 'public' => true,
89
+ 'show_ui' => true,
90
+ '_builtin' => false
91
+ );
92
+ $output = 'objects'; // names or objects, note names is the default
93
+ $operator = 'and'; // 'and' or 'or'
94
+ $post_types = get_post_types($args, $output, $operator);
95
+ if (! empty($post_types)) { ?>
96
+ <div class="form-group">
97
+ <label style="margin-bottom:-5px;"><?php _e('Enable Gmedia Library button on custom post types', 'grand-media') ?>:</label>
98
+ <input type="hidden" name="set[gmedia_post_types_support]" value=""/>
99
+ <?php
100
+ foreach ($post_types as $post_type) { ?>
101
+ <div class="checkbox"><label><input type="checkbox" name="set[gmedia_post_types_support][]" value="<?php echo $post_type->name; ?>" <?php echo in_array($post_type->name, $allowed_post_types)? 'checked="checked"' : ''; ?> /> <?php echo $post_type->label . ' (' . $post_type->name . ')'; ?></label> </div>
102
+ <?php } ?>
103
+ </div>
104
+ <?php } ?>
105
+ </fieldset>
106
+
admin/pages/settings/tpl/license.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * License Key
4
+ */
5
+ ?>
6
+ <fieldset id="gmedia_premium" class="tab-pane active">
7
+ <p><?php _e('Enter License Key to remove backlink label from premium gallery modules.') ?></p>
8
+
9
+ <div class="row">
10
+ <div class="form-group col-xs-5">
11
+ <label><?php _e('License Key', 'grand-media') ?>: <?php if (isset($gmGallery->options['license_name'])) {
12
+ echo '<em>' . $gmGallery->options['license_name'] . '</em>';
13
+ } ?></label>
14
+ <input type="text" name="set[license_key]" id="license_key" class="form-control input-sm" value="<?php echo $lk; ?>"/>
15
+
16
+ <div class="manual_license_activate"<?php echo(('manual' == $gmCore->_get('license_activate')) ? '' : ' style="display:none;"'); ?>>
17
+ <label style="margin-top:7px;"><?php _e('License Name', 'grand-media') ?>:</label>
18
+ <input type="text" name="set[license_name]" id="license_name" class="form-control input-sm" value="<?php echo $gmGallery->options['license_name']; ?>"/>
19
+ <label style="margin-top:7px;"><?php _e('Additional Key', 'grand-media') ?>:</label>
20
+ <input type="text" name="set[license_key2]" id="license_key2" class="form-control input-sm" value="<?php echo $gmGallery->options['license_key2']; ?>"/>
21
+ </div>
22
+ </div>
23
+ <?php if (! ('manual' == $gmCore->_get('license_activate') || ! empty($lk))) { ?>
24
+ <div class="form-group col-xs-7">
25
+ <label>&nbsp;</label>
26
+ <button style="display:block;" class="btn btn-success btn-sm" type="submit" name="license-key-activate"><?php _e('Activate Key', 'grand-media'); ?></button>
27
+ </div>
28
+ <?php } ?>
29
+ </div>
30
+ </fieldset>
admin/pages/settings/tpl/permalinks.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Permalinks and GmediaCloud page settings
4
+ *
5
+ * @var $gmGallery
6
+ * @var $gmDB
7
+ * @var $gmCore
8
+ * @var $user_ID
9
+ */
10
+ ?>
11
+ <fieldset id="gmedia_settings_permalinks" class="tab-pane">
12
+ <h4><?php _e('Gmedia Library Items', 'grand-media'); ?></h4>
13
+ <div class="form-group">
14
+ <label><?php _e('Gmedia Base', 'grand-media') ?>:</label>
15
+ <input type="text" name="set[gmedia_post_slug]" value="<?php echo $gmGallery->options['gmedia_post_slug']; ?>" class="form-control input-sm"/>
16
+
17
+ <p class="help-block"><?php _e('Base for gmedia post url.', 'grand-media'); ?></p>
18
+ </div>
19
+ <div class="form-group">
20
+ <div class="checkbox" style="margin:0;">
21
+ <input type="hidden" name="set[gmedia_exclude_from_search]" value="0"/>
22
+ <label><input type="checkbox" name="set[gmedia_exclude_from_search]" value="1" <?php checked($gmGallery->options['gmedia_exclude_from_search'], '1'); ?> /> <?php _e('Exclude Gmedia Library Items from WordPress search results on the Frontend', 'grand-media'); ?> </label>
23
+ </div>
24
+ </div>
25
+ <div class="form-group">
26
+ <label><?php _e('Default comment status for new gmedia items', 'grand-media') ?>:</label>
27
+ <select name="set[default_gmedia_comment_status]" class="form-control input-sm">
28
+ <option value="open" <?php selected($gmGallery->options['default_gmedia_comment_status'], 'open'); ?>><?php _e('Open', 'grand-media'); ?></option>
29
+ <option value="closed" <?php selected($gmGallery->options['default_gmedia_comment_status'], 'closed'); ?>><?php _e('Closed', 'grand-media'); ?></option>
30
+ </select>
31
+
32
+ <p class="help-block"><?php _e('(These setting may be overridden for individual gmedia items.)', 'grand-media'); ?></p>
33
+ </div>
34
+
35
+ <hr />
36
+ <h4><?php _e('Gmedia Albums', 'grand-media'); ?></h4>
37
+ <div class="form-group">
38
+ <label><?php _e('Gmedia Album Base', 'grand-media') ?>:</label>
39
+ <input type="text" name="set[gmedia_album_post_slug]" value="<?php echo $gmGallery->options['gmedia_album_post_slug']; ?>" class="form-control input-sm"/>
40
+
41
+ <p class="help-block"><?php _e('Base for gmedia album post url.', 'grand-media'); ?></p>
42
+ </div>
43
+ <div class="form-group">
44
+ <div class="checkbox" style="margin:0;">
45
+ <input type="hidden" name="set[gmedia_album_exclude_from_search]" value="0"/>
46
+ <label><input type="checkbox" name="set[gmedia_album_exclude_from_search]" value="1" <?php checked($gmGallery->options['gmedia_album_exclude_from_search'], '1'); ?> /> <?php _e('Exclude Gmedia Albums from WordPress search results on the Frontend', 'grand-media'); ?> </label>
47
+ </div>
48
+ </div>
49
+
50
+ <hr />
51
+ <h4><?php _e('Gmedia Custom Filters', 'grand-media'); ?></h4>
52
+ <div class="form-group">
53
+ <label><?php _e('Gmedia Custom Filter Base', 'grand-media') ?>:</label>
54
+ <input type="text" name="set[gmedia_filter_post_slug]" value="<?php echo $gmGallery->options['gmedia_filter_post_slug']; ?>" class="form-control input-sm"/>
55
+
56
+ <p class="help-block"><?php _e('Base for gmedia filter post url.', 'grand-media'); ?></p>
57
+ </div>
58
+ <div class="form-group">
59
+ <div class="checkbox" style="margin:0;">
60
+ <input type="hidden" name="set[gmedia_filter_exclude_from_search]" value="0"/>
61
+ <label><input type="checkbox" name="set[gmedia_filter_exclude_from_search]" value="1" <?php checked($gmGallery->options['gmedia_filter_exclude_from_search'], '1'); ?> /> <?php _e('Exclude Gmedia Custom Filters from WordPress search results on the Frontend', 'grand-media'); ?> </label>
62
+ </div>
63
+ </div>
64
+
65
+ <hr />
66
+ <h4><?php _e('Gmedia Galleries', 'grand-media'); ?></h4>
67
+ <div class="form-group">
68
+ <label><?php _e('Gmedia Gallery Base', 'grand-media') ?>:</label>
69
+ <input type="text" name="set[gmedia_gallery_post_slug]" value="<?php echo $gmGallery->options['gmedia_gallery_post_slug']; ?>" class="form-control input-sm"/>
70
+
71
+ <p class="help-block"><?php _e('Base for gmedia gallery post url.', 'grand-media'); ?></p>
72
+ </div>
73
+ <div class="form-group">
74
+ <div class="checkbox" style="margin:0;">
75
+ <input type="hidden" name="set[gmedia_gallery_exclude_from_search]" value="0"/>
76
+ <label><input type="checkbox" name="set[gmedia_gallery_exclude_from_search]" value="1" <?php checked($gmGallery->options['gmedia_gallery_exclude_from_search'], '1'); ?> /> <?php _e('Exclude Gmedia Galleries from WordPress search results on the Frontend', 'grand-media'); ?> </label>
77
+ </div>
78
+ </div>
79
+ </fieldset>
80
+
81
+ <fieldset id="gmedia_settings_cloud" class="tab-pane">
82
+ <p><?php _e('GmediaCloud is full window template to show your galleries, albums and other gmedia content', 'grand-media'); ?></p>
83
+
84
+ <p><?php _e('Each module can have it\'s own design for GmediaCloud. Here you can set default module wich will be used for sharing Albums, Tags, Categories and single Gmedia Items.', 'grand-media'); ?></p>
85
+ <br/>
86
+
87
+ <div class="form-group">
88
+ <label><?php _e('HashID salt for unique template URL', 'grand-media') ?>:</label>
89
+ <input type="text" name="GmediaHashID_salt" value="<?php echo get_option('GmediaHashID_salt'); ?>" class="form-control input-sm"/>
90
+
91
+ <p class="help-block"><?php _e('Changing this string you\'ll change Gmedia template URLs.', 'grand-media'); ?></p>
92
+ </div>
93
+ <div class="form-group">
94
+ <label><?php _e('Permalink Endpoint (GmediaCloud base)', 'grand-media') ?>:</label>
95
+ <input type="text" name="set[endpoint]" value="<?php echo $gmGallery->options['endpoint']; ?>" class="form-control input-sm"/>
96
+
97
+ <p class="help-block"><?php _e('Changing endpoint you\'ll change Gmedia template URLs.', 'grand-media'); ?></p>
98
+ </div>
99
+ <?php
100
+ $modules = array();
101
+ if (($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
102
+ foreach ($plugin_modules as $path) {
103
+ if (! file_exists($path . '/index.php')) {
104
+ continue;
105
+ }
106
+ $module_info = array();
107
+ /** @noinspection PhpIncludeInspection */
108
+ include($path . '/index.php');
109
+ if (empty($module_info)) {
110
+ continue;
111
+ }
112
+ $mfold = basename($path);
113
+ $modules[$mfold] = array(
114
+ 'module_name' => $mfold,
115
+ 'module_title' => $module_info['title'] . ' v' . $module_info['version'],
116
+ 'module_url' => $gmCore->gmedia_url . "/module/{$mfold}",
117
+ 'module_path' => $path
118
+ );
119
+ }
120
+ }
121
+ if (($upload_modules = glob($gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
122
+ foreach ($upload_modules as $path) {
123
+ if (! file_exists($path . '/index.php')) {
124
+ continue;
125
+ }
126
+ $module_info = array();
127
+ /** @noinspection PhpIncludeInspection */
128
+ include($path . '/index.php');
129
+ if (empty($module_info)) {
130
+ continue;
131
+ }
132
+ $mfold = basename($path);
133
+ $modules[$mfold] = array(
134
+ 'module_name' => $mfold,
135
+ 'module_title' => $module_info['title'] . ' v' . $module_info['version'],
136
+ 'module_url' => $gmCore->upload['url'] . "/{$gmGallery->options['folder']['module']}/{$mfold}",
137
+ 'module_path' => $path
138
+ );
139
+ }
140
+ }
141
+ ?>
142
+ <div class="form-group">
143
+ <label><?php _e('Choose module/preset for GmediaCloud Page', 'grand-media') ?>:</label>
144
+ <select class="form-control input-sm" name="set[gmediacloud_module]">
145
+ <option value=""><?php _e('Choose module/preset', 'grand-media'); ?></option>
146
+ <?php foreach ($modules as $mfold => $module) {
147
+ echo '<optgroup label="' . esc_attr($module['module_title']) . '">';
148
+ $presets = $gmDB->get_terms('gmedia_module', array('global' => $user_ID, 'status' => $mfold));
149
+ $selected = selected($gmGallery->options['gmediacloud_module'], esc_attr($mfold), false);
150
+ $option = array();
151
+ $option['default'] = '<option ' . $selected . ' value="' . esc_attr($mfold) . '">' . '[' . $mfold . '] ' . __('Default Settings') . '</option>';
152
+ foreach ($presets as $preset) {
153
+ $selected = selected($gmGallery->options['gmediacloud_module'], $preset->term_id, false);
154
+ if ('[' . $mfold . ']' == $preset->name) {
155
+ $option['default'] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . '[' . $mfold . '] ' . __('Default Settings') . '</option>';
156
+ } else {
157
+ $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . $preset->name . '</option>';
158
+ }
159
+ }
160
+ echo implode('', $option);
161
+ echo '</optgroup>';
162
+ } ?>
163
+ </select>
164
+
165
+ <p class="help-block"><?php _e('by default will be used Phantom module', 'grand-media'); ?></p>
166
+ </div>
167
+ <div class="form-group">
168
+ <label><?php _e('Top Bar Social Buttons', 'grand-media'); ?></label>
169
+ <select name="set[gmediacloud_socialbuttons]" class="form-control input-sm">
170
+ <option value="1" <?php selected($gmGallery->options['gmediacloud_socialbuttons'], '1'); ?>><?php _e('Show Social Buttons', 'grand-media'); ?></option>
171
+ <option value="0" <?php selected($gmGallery->options['gmediacloud_socialbuttons'], '0'); ?>><?php _e('Hide Social Buttons', 'grand-media'); ?></option>
172
+ </select>
173
+ </div>
174
+ <div class="form-group">
175
+ <label><?php _e('Additional JS code for GmediaCloud Page', 'grand-media') ?>:</label>
176
+ <textarea name="set[gmediacloud_footer_js]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_html(stripslashes($gmGallery->options['gmediacloud_footer_js'])); ?></textarea>
177
+ </div>
178
+ <div class="form-group">
179
+ <label><?php _e('Additional CSS code for GmediaCloud Page', 'grand-media') ?>:</label>
180
+ <textarea name="set[gmediacloud_footer_css]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_html(stripslashes($gmGallery->options['gmediacloud_footer_css'])); ?></textarea>
181
+ </div>
182
+ </fieldset>
admin/pages/settings/tpl/roles.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Capabilities Manager
4
+ *
5
+ * @var $gmDB
6
+ */
7
+ ?>
8
+ <fieldset id="gmedia_settings_roles" class="tab-pane">
9
+ <p><?php _e('Select the lowest role which should be able to access the follow capabilities. Gmedia Gallery supports the standard roles from WordPress.', 'grand-media'); ?></p>
10
+
11
+ <div class="form-group">
12
+ <label><?php _e('Gmedia Library', 'grand-media') ?>:</label>
13
+ <select name="capability[gmedia_library]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_library')); ?></select>
14
+
15
+ <p class="help-block"><?php _e('Who can view Gmedia Gallery admin pages', 'grand-media'); ?></p>
16
+ </div>
17
+ <hr/>
18
+
19
+ <div class="form-group">
20
+ <label><?php _e('Upload Media Files', 'grand-media') ?>:</label>
21
+ <select name="capability[gmedia_upload]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_upload')); ?></select>
22
+
23
+ <p class="help-block"><?php _e('Who can upload files to Gmedia Library', 'grand-media'); ?></p>
24
+ </div>
25
+ <div class="col-xs-offset-1">
26
+ <div class="form-group">
27
+ <label><?php _e('Import Media Files', 'grand-media') ?>:</label>
28
+ <select name="capability[gmedia_import]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_import')); ?></select>
29
+
30
+ <p class="help-block"><?php _e('Who can import files to Gmedia Library', 'grand-media'); ?></p>
31
+ </div>
32
+ </div>
33
+
34
+ <div class="form-group">
35
+ <label><?php _e('Show Others Media in Library', 'grand-media') ?>:</label>
36
+ <select name="capability[gmedia_show_others_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_show_others_media')); ?></select>
37
+
38
+ <p class="help-block"><?php _e('Who can see files uploaded by other users', 'grand-media'); ?></p>
39
+ </div>
40
+ <div class="form-group">
41
+ <label><?php _e('Edit Media', 'grand-media') ?>:</label>
42
+ <select name="capability[gmedia_edit_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_edit_media')); ?></select>
43
+
44
+ <p class="help-block"><?php _e('Who can edit media title, description and other properties of uploaded files', 'grand-media'); ?></p>
45
+ </div>
46
+ <div class="col-xs-offset-1">
47
+ <div class="form-group">
48
+ <label><?php _e('Edit Others Media', 'grand-media') ?>:</label>
49
+ <select name="capability[gmedia_edit_others_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_edit_others_media')); ?></select>
50
+
51
+ <p class="help-block"><?php _e('Who can edit files, albums/tags and galleries of other users', 'grand-media'); ?></p>
52
+ </div>
53
+ </div>
54
+ <div class="form-group">
55
+ <label><?php _e('Delete Media', 'grand-media') ?>:</label>
56
+ <select name="capability[gmedia_delete_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_delete_media')); ?></select>
57
+
58
+ <p class="help-block"><?php _e('Who can delete uploaded files from Gmedia Library', 'grand-media'); ?></p>
59
+ </div>
60
+ <div class="col-xs-offset-1">
61
+ <div class="form-group">
62
+ <label><?php _e('Delete Others Media', 'grand-media') ?>:</label>
63
+ <select name="capability[gmedia_delete_others_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_delete_others_media')); ?></select>
64
+
65
+ <p class="help-block"><?php _e('Who can delete files, albums/tags and galleries of other users', 'grand-media'); ?></p>
66
+ </div>
67
+ </div>
68
+
69
+ <div class="form-group">
70
+ <label><?php _e('Albums, Tags...', 'grand-media') ?>:</label>
71
+ <select name="capability[gmedia_terms]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_terms')); ?></select>
72
+
73
+ <p class="help-block"><?php _e('Who can assign available terms to media files', 'grand-media'); ?></p>
74
+ </div>
75
+ <div class="col-xs-offset-1">
76
+ <div class="form-group">
77
+ <label><?php _e('Manage Albums', 'grand-media') ?>:</label>
78
+ <select name="capability[gmedia_album_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_album_manage')); ?></select>
79
+
80
+ <p class="help-block"><?php _e('Who can create and edit own albums. It is required "Edit Others Media" capability to edit others and shared albums', 'grand-media'); ?></p>
81
+ </div>
82
+ <div class="form-group">
83
+ <label><?php _e('Manage Filters', 'grand-media') ?>:</label>
84
+ <select name="capability[gmedia_filter_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_filter_manage')); ?></select>
85
+
86
+ <p class="help-block"><?php _e('Who can create and edit own custom filters. It is required "Edit Others Media" capability to edit filters you do not own', 'grand-media'); ?></p>
87
+ </div>
88
+ <div class="form-group">
89
+ <label><?php _e('Manage Tags', 'grand-media') ?>:</label>
90
+ <select name="capability[gmedia_tag_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_tag_manage')); ?></select>
91
+
92
+ <p class="help-block"><?php _e('Who can create new tags. It is required "Edit Others Media" capability to edit tags', 'grand-media'); ?></p>
93
+ </div>
94
+ <div class="form-group">
95
+ <label><?php _e('Delete Terms', 'grand-media') ?>:</label>
96
+ <select name="capability[gmedia_terms_delete]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_terms_delete')); ?></select>
97
+
98
+ <p class="help-block"><?php _e('Who can delete own albums. It is required "Delete Others Media" capability to delete others terms', 'grand-media'); ?></p>
99
+ </div>
100
+ </div>
101
+
102
+ <div class="form-group">
103
+ <label><?php _e('Galleries', 'grand-media') ?>:</label>
104
+ <select name="capability[gmedia_gallery_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_gallery_manage')); ?></select>
105
+
106
+ <p class="help-block"><?php _e('Who can create, edit and delete own galleries', 'grand-media'); ?></p>
107
+ </div>
108
+
109
+ <div class="form-group">
110
+ <label><?php _e('Modules', 'grand-media') ?>:</label>
111
+ <select name="capability[gmedia_module_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_module_manage')); ?></select>
112
+
113
+ <p class="help-block"><?php _e('Who can manage modules', 'grand-media'); ?></p>
114
+ </div>
115
+
116
+ <div class="form-group">
117
+ <label><?php _e('Settings', 'grand-media') ?>:</label>
118
+ <select name="capability[gmedia_settings]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_settings')); ?></select>
119
+
120
+ <p class="help-block"><?php _e('Who can change settings. Note: Capabilites can be changed only by administrator', 'grand-media'); ?></p>
121
+ </div>
122
+
123
+ </fieldset>
admin/pages/settings/tpl/system.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * System info (under constraction)
4
+ */
5
+ ?>
6
+ <fieldset id="gmedia_settings_sysinfo" class="tab-pane">
7
+ <?php
8
+ if ((function_exists('memory_get_usage')) && (ini_get('memory_limit'))) {
9
+ $memory_limit = ini_get('memory_limit');
10
+ $memory_usage = round(memory_get_usage() / (1024 * 1024), 1);
11
+ echo '<p>' . __('PHP Memory Limit: ', 'grand-media') . $memory_limit . '</p>';
12
+ echo '<p>' . __('PHP Memory Used: ', 'grand-media') . $memory_usage . 'M</p>';
13
+ }
14
+ ?>
15
+ <p><?php _e('Under constraction...') ?></p>
16
+
17
+ <?php
18
+ if ($gmCore->_get('showdb')) {
19
+ global $wpdb;
20
+ $gmedia = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia");
21
+ $terms = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia_term");
22
+ $relation = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia_term_relationships");
23
+ $images['grand-media'] = glob($gmCore->upload['path'] . '/*', GLOB_NOSORT);
24
+ $images['images'] = glob($gmCore->upload['path'] . '/image/*', GLOB_NOSORT);
25
+ $images['thumbs'] = glob($gmCore->upload['path'] . '/thumb/*', GLOB_NOSORT);
26
+ echo '<pre style="max-height:400px; overflow:auto;">' . print_r($gmedia, true) . '</pre>';
27
+ echo '<pre style="max-height:400px; overflow:auto;">' . print_r($images, true) . '</pre>';
28
+ echo '<pre style="max-height:400px; overflow:auto;">' . print_r($terms, true) . '</pre>';
29
+ echo '<pre style="max-height:400px; overflow:auto;">' . print_r($relation, true) . '</pre>';
30
+ }
31
+ ?>
32
+ </fieldset>
33
+
admin/pages/taxonomy/edit-album.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Gmedia Term (Album) Edit
4
+ */
5
+
6
+ // don't load directly
7
+ if(!defined('ABSPATH')) {
8
+ die('-1');
9
+ }
10
+
11
+ global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
+
13
+ $gmedia_url = $gmProcessor->url;
14
+ $gmedia_user_options = $gmProcessor->user_options;
15
+ $gmedia_term_taxonomy = $gmProcessor->taxonomy;
16
+ $taxterm = str_replace('gmedia_', '', $gmedia_term_taxonomy);
17
+
18
+ if(!gm_user_can("{$taxterm}_manage")) {
19
+ die('-1');
20
+ }
21
+
22
+ $term_id = $gmCore->_get('edit_item');
23
+ $term = $gmDB->get_term($term_id, $gmedia_term_taxonomy);
24
+
25
+ if(empty($term) || is_wp_error($term)) {
26
+ return;
27
+ }
28
+ gmedia_term_item_more_data($term);
29
+
30
+ do_action('gmedia_term_before_panel');
31
+ ?>
32
+
33
+ <div class="panel panel-default">
34
+
35
+ <?php
36
+ include(dirname(__FILE__) . '/tpl/term-panel-heading.php');
37
+
38
+ include(dirname(__FILE__) . "/tpl/{$taxterm}-edit-item.php");
39
+ ?>
40
+
41
+ </div>
42
+
43
+ <?php
44
+ do_action("gmedia_term_{$taxterm}_after_panel", $term);
45
+ do_action('gmedia_term_after_panel');
46
+ ?>
admin/pages/taxonomy/edit-filter.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Gmedia Filter Edit
4
+ */
5
+
6
+ // don't load directly
7
+ if(!defined('ABSPATH')) {
8
+ die('-1');
9
+ }
10
+
11
+ global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
+
13
+ $gmedia_url = $gmProcessor->url;
14
+ $gmedia_user_options = $gmProcessor->user_options;
15
+ $gmedia_term_taxonomy = $gmProcessor->taxonomy;
16
+ $taxterm = str_replace('gmedia_', '', $gmedia_term_taxonomy);
17
+
18
+ if(!gm_user_can("filter_manage")) {
19
+ die('-1');
20
+ }
21
+
22
+ $term_id = $gmCore->_get('edit_item');
23
+ $per_page = 40;
24
+ $cur_page = $gmCore->_get('pager', 1);
25
+
26
+ $author_new = false;
27
+ if(gm_user_can('edit_others_media')) {
28
+ $author = (int)$gmCore->_get('author', $user_ID);
29
+ } else {
30
+ $author = $user_ID;
31
+ }
32
+
33
+ $pager_html = '';
34
+ $term = array(
35
+ 'name' => '',
36
+ 'description' => '',
37
+ 'global' => $author
38
+ );
39
+
40
+ $filter_data = array(
41
+ 'author__in' => array()
42
+ , 'author__not_in' => array()
43
+ , 'category__in' => array() // use category id. Same as 'cat', but does not accept negative values
44
+ , 'category__not_in' => array() // use category id. Exclude multiple categories
45
+ , 'album__in' => array() // use album id. Same as 'alb'
46
+ , 'album__not_in' => array() // use album id. Exclude multiple albums
47
+ , 'tag__and' => array() // use tag ids. Display posts that are tagged with all listed tags in array
48
+ , 'tag__in' => array() // use tag ids. To display posts from either tags listed in array. Same as 'tag'
49
+ , 'tag__not_in' => array() // use tag ids. Display posts that do not have any of the listed tag ids
50
+ , 'terms_relation' => '' // allows you to describe the boolean relationship between the taxonomy queries. Possible values are 'OR', 'AND'. Default 'AND'
51
+ , 'gmedia__in' => array() // use gmedia ids. Specify posts to retrieve
52
+ , 'gmedia__not_in' => array() // use gmedia ids. Specify post NOT to retrieve
53
+ , 'mime_type' => array() // mime types
54
+
55
+ , 'limit' => '' // (int) - set limit
56
+ , 'per_page' => '' // (int) - set limit
57
+ , 'order' => '' // Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'
58
+ , 'orderby' => '' // Sort retrieved posts by parameter. Defaults to 'ID'
59
+ , 'year' => '' // (int) - 4 digit year
60
+ , 'monthnum' => '' // (int) - Month number (from 1 to 12)
61
+ , 'day' => '' // (int) - Day of the month (from 1 to 31)
62
+
63
+ , 'meta_query' => array(
64
+ array(
65
+ 'key' => '',
66
+ 'value' => '',
67
+ 'compare' => '',
68
+ 'type' => ''
69
+ )
70
+ )
71
+ , 's' => '' // (string) - search string or terms separated by comma
72
+ , 'exact' => false // Search exactly string if 'exact' parameter set to true
73
+
74
+ );
75
+
76
+ $filter_variable_data = $term_query = array(
77
+ 'cache_results' => false,
78
+ 'page' => $cur_page, // number of page. Show the posts that would normally show up just on page X.
79
+ 'per_page' => $per_page // number of post to displace or pass over. Note: Setting offset parameter will ignore the 'page' parameter.
80
+ );
81
+
82
+ $filter_form_custom_data = array(
83
+ 'gmedia_album' => array(),
84
+ 'gmedia_category' => array(),
85
+ 'gmedia_tag' => array(),
86
+ 'gmedia_id' => array(),
87
+ 'author_id' => array(),
88
+ 'album__condition' => 'album__in',
89
+ 'category__condition' => 'category__in',
90
+ 'tag__condition' => 'tag__in',
91
+ 'gmedia_id__condition' => 'gmedia__in',
92
+ 'author_id__condition' => 'author__in'
93
+ );
94
+ /**
95
+ * @var $gmedia_album
96
+ * @var $gmedia_category
97
+ * @var $gmedia_tag
98
+ * @var $gmedia_id
99
+ * @var $author_id
100
+ * @var $album__condition
101
+ * @var $category__condition
102
+ * @var $tag__condition
103
+ * @var $gmedia_id__condition
104
+ * @var $author_id__condition
105
+ */
106
+ extract($filter_form_custom_data);
107
+
108
+ $totalResult = 0;
109
+ $trueTotalResult = 0;
110
+ if($term_id) {
111
+ $term = $gmDB->get_term($term_id, $gmedia_term_taxonomy, ARRAY_A);
112
+ if(!empty($term) && !is_wp_error($term)) {
113
+
114
+ $term_query = $gmDB->get_metadata('gmedia_term', $term['term_id'], '_query', true);
115
+ $filter_data = array_merge($filter_data, $term_query);
116
+
117
+ $term_query = array_merge($filter_variable_data, $term_query);
118
+
119
+ if(isset($_GET['author']) && ($term['global'] != $author)) {
120
+ $filter_data['_query']['gmedia_album'] = array();
121
+ $term['global'] = $author;
122
+ $author_new = true;
123
+ }
124
+
125
+ if(!empty($filter_data['album__not_in'])) {
126
+ $album__condition = 'album__not_in';
127
+ }
128
+ $gmedia_album = $filter_data[$album__condition];
129
+
130
+ if(!empty($filter_data['category__not_in'])) {
131
+ $category__condition = 'category__not_in';
132
+ }
133
+ $gmedia_category = $filter_data[$category__condition];
134
+
135
+ if(!empty($filter_data['tag__not_in'])) {
136
+ $tag__condition = 'tag__not_in';
137
+ } elseif(!empty($filter_data['tag__and'])) {
138
+ $tag__condition = 'tag__and';
139
+ }
140
+ $gmedia_tag = $filter_data[$tag__condition];
141
+
142
+ if(!empty($filter_data['gmedia__not_in'])) {
143
+ $gmedia_id__condition = 'gmedia__not_in';
144
+ }
145
+ $gmedia_id = $filter_data[$gmedia_id__condition];
146
+
147
+ if(!empty($filter_data['author__not_in'])) {
148
+ $author_id__condition = 'author__not_in';
149
+ }
150
+ $author_id = $filter_data[$author_id__condition];
151
+
152
+ $termItems = $gmDB->get_gmedias($term_query);
153
+ $totalResult = (int)$gmDB->totalResult;
154
+ if(!$totalResult && !empty($termItems)) {
155
+ $totalResult = count($termItems);
156
+ }
157
+ if(!empty($gmDB->trueTotalResult)) {
158
+ $trueTotalResult = $gmDB->trueTotalResult;
159
+ }
160
+
161
+ if(!empty($termItems)) {
162
+ $pager_html = $gmDB->query_pager();
163
+ }
164
+ } else {
165
+ $term_id = 0;
166
+ }
167
+ }
168
+
169
+ do_action('gmedia_term_before_panel');
170
+ ?>
171
+
172
+ <div class="panel panel-default">
173
+
174
+ <?php
175
+ include(dirname(__FILE__) . '/tpl/term-panel-heading.php');
176
+
177
+ include(dirname(__FILE__) . "/tpl/filter-edit-item.php");
178
+ ?>
179
+
180
+ </div>
181
+
182
+ <div class="panel panel-default" id="queryfilter">
183
+ <div class="panel-heading clearfix">
184
+ <h4 style="margin:7px 0;" class="pull-left"><?php _e('Query Filter'); ?></h4>
185
+ <?php echo $pager_html; ?>
186
+ </div>
187
+ <div class="panel-body">
188
+ <div class="termItems clearfix">
189
+ <?php if(!empty($termItems)) {
190
+ foreach($termItems as $item) {
191
+ $item_class = '';
192
+ ?>
193
+ <div class="gm-img-thumbnail<?php echo $item_class; ?>" data-gmid="<?php echo $item->ID; ?>"><?php
194
+ ?><img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt="<?php echo $item->ID; ?>" title="<?php echo esc_attr($item->title); ?>"/><?php
195
+ ?><span class="label label-default">ID: <?php echo $item->ID; ?></span><?php
196
+ ?>
197
+ <div class="gm-img-thumb-title"><?php echo esc_html($item->title); ?></div>
198
+ </div>
199
+ <?php
200
+ }
201
+ } else {
202
+ if($term_id) { ?>
203
+ <p class="text-center"><?php _e('No items with selected parameters.') ?></p>
204
+ <?php } else { ?>
205
+ <p class="text-center"><?php _e('Set Filter parameters and click Save button to test query.') ?></p>
206
+ <?php }
207
+ } ?>
208
+ </div>
209
+ </div>
210
+ <div class="panel-footer clearfix" style="margin-top:20px;"><?php echo $pager_html; ?>
211
+ <?php if($trueTotalResult) { ?>
212
+ <div class="well well-sm pull-left" style="margin-right:10px;"><?php printf(__('Limited to: %d'), $totalResult); ?></div>
213
+ <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $trueTotalResult); ?></div>
214
+ <?php } else { ?>
215
+ <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $totalResult); ?></div>
216
+ <?php } ?>
217
+ </div>
218
+ </div>
219
+
220
+ <?php
221
+ do_action('gmedia_term_after_panel');
222
+ ?>
admin/pages/taxonomy/functions.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function gmedia_term_item_thumbnails($term_item, $qty = 7) {
4
+ global $gmCore, $gmDB, $gmGallery;
5
+ ?>
6
+ <div class="term-images">
7
+ <?php
8
+ if($term_item->count) {
9
+ $term__in = str_replace('gmedia_', '', $term_item->taxonomy) . '__in';
10
+ switch($term_item->taxonomy) {
11
+ case 'gmedia_tag':
12
+ $orderby = $gmGallery->options['in_tag_orderby'];
13
+ $order = $gmGallery->options['in_tag_order'];
14
+ break;
15
+ case 'gmedia_category':
16
+ $orderby = $gmGallery->options['in_category_orderby'];
17
+ $order = $gmGallery->options['in_category_order'];
18
+ break;
19
+ default:
20
+ $orderby = 'ID';
21
+ $order = 'DESC';
22
+ break;
23
+ }
24
+ $args = array(
25
+ 'no_found_rows' => true,
26
+ 'per_page' => $qty,
27
+ $term__in => array($term_item->term_id),
28
+ 'author' => gm_user_can('show_others_media')? 0 : get_current_user_id(),
29
+ 'orderby' => isset($term_item->meta['_orderby'][0])? $term_item->meta['_orderby'][0] : $orderby,
30
+ 'order' => isset($term_item->meta['_order'][0])? $term_item->meta['_order'][0] : $order
31
+ );
32
+
33
+ $gmedias = $gmDB->get_gmedias($args);
34
+ if(!empty($gmedias)) {
35
+ foreach($gmedias as $gmedia_item) {
36
+ ?>
37
+ <img style="z-index:<?php echo $qty--; ?>;" src="<?php echo $gmCore->gm_get_media_image($gmedia_item, 'thumb', false); ?>" alt="<?php echo $gmedia_item->ID; ?>" title="<?php echo esc_attr($gmedia_item->title); ?>"/>
38
+ <?php
39
+ }
40
+ }
41
+ if(count($gmedias) < $term_item->count) {
42
+ echo '...';
43
+ }
44
+ }
45
+ ?>
46
+ </div>
47
+ <?php
48
+ }
49
+
50
+ function gmedia_term_item_actions($item) {
51
+ global $gmCore, $gmProcessor;
52
+
53
+ $taxterm = str_replace('gmedia_', '', $item->taxonomy);
54
+ $actions = array();
55
+
56
+ $filter_href = $gmCore->get_admin_url(array('page' => 'GrandMedia', "{$taxterm}__in" => $item->term_id), array(), true);
57
+ $filter_class = 'gm_filter_in_lib';
58
+ $count = '';
59
+ if(in_array($item->taxonomy, array('gmedia_album', 'gmedia_tag', 'gmedia_category'))) {
60
+ $count = '<span class="gm_term_count">' . $item->count . '</span>';
61
+ if(!$item->count) {
62
+ $filter_class .= ' action-inactive';
63
+ }
64
+ }
65
+ $actions['filter'] = '<a title="' . __('Filter in Gmedia Library', 'grand-media') . '" href="' . $filter_href . '" class="' . $filter_class . '">' . $count . '<span class="glyphicon glyphicon-filter"></span></a>';
66
+
67
+ $cloud_link = $gmCore->gmcloudlink($item->term_id, $taxterm);
68
+ if(!empty($item->meta['_post_ID'][0])){
69
+ $post_link = get_permalink($item->meta['_post_ID'][0]);
70
+ } else {
71
+ $post_link = '';
72
+ }
73
+ $share_icon = '<span class="glyphicon glyphicon-share"></span>';
74
+ if('draft' !== $item->status) {
75
+ $actions['share'] = '<a target="_blank" data-target="#shareModal" data-share="' . $item->term_id . '" class="share-modal" title="' . __('Share', 'grand-media') . '" data-gmediacloud="' . $cloud_link . '" href="' . $post_link . '">' . $share_icon . '</a>';
76
+ } else {
77
+ $actions['share'] = "<span class='action-inactive'>$share_icon</span>";
78
+ }
79
+
80
+ if('gmedia_category' != $item->taxonomy) {
81
+ if('gmedia_tag' != $item->taxonomy) {
82
+ $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
83
+ if($item->allow_edit) {
84
+ $actions['edit'] = '<a title="' . __('Edit', 'grand-media') . '" href="' . add_query_arg(array("edit_item" => $item->term_id), $gmProcessor->url) . '">' . $edit_icon . '</a>';
85
+ } else {
86
+ $actions['edit'] = "<span class='action-inactive'>$edit_icon</span>";
87
+ }
88
+ }
89
+
90
+ $trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
91
+ if($item->allow_delete) {
92
+ $actions['delete'] = '<a class="trash-icon" title="' . __('Delete', 'grand-media') . '" href="' . wp_nonce_url(add_query_arg(array('delete' => $item->term_id), $gmProcessor->url), 'gmedia_delete') . '" data-confirm="' . __("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media") . '">' . $trash_icon . '</a>';
93
+ } else {
94
+ $actions['delete'] = "<span class='action-inactive'>$trash_icon</span>";
95
+ }
96
+
97
+ /*if(gm_user_can("{$item->taxonomy}_manage")) {
98
+ if((int)$item->global === get_current_user_id() || gm_user_can('edit_others_media')) {
99
+ $action['edit'] = '<a title="' . __('Edit', 'grand-media') . '" href="' . add_query_arg(array("edit_item" => $item->term_id), $gmProcessor->url) . '">' . $edit_icon . '</a>';
100
+
101
+ if(gm_user_can('terms_delete')) {
102
+ $action['delete'] = '<a class="trash-icon" title="' . __('Delete', 'grand-media') . '" href="' . wp_nonce_url(add_query_arg(array('delete' => $item->term_id), $gmProcessor->url), 'gmedia_delete') . '" data-confirm="' . __("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media") . '">' . $trash_icon . '</a>';
103
+ }
104
+ }
105
+ }*/
106
+ }
107
+
108
+
109
+ return apply_filters('gmedia_term_item_actions', $actions);
110
+ }
111
+
112
+
113
+ function gmedia_term_item_more_data(&$item) {
114
+ global $gmDB, $gmGallery;
115
+
116
+ $meta = $gmDB->get_metadata('gmedia_term', $item->term_id);
117
+ $item->meta = $meta;
118
+
119
+ if($item->global) {
120
+ $item->author_name = get_the_author_meta('display_name', $item->global);
121
+ } else {
122
+ $item->author_name = false;
123
+ }
124
+
125
+ if('gmedia_album' == $item->taxonomy || 'gmedia_filter' == $item->taxonomy) {
126
+ $post_id = isset($meta['_post_ID'][0])? (int)$meta['_post_ID'][0] : 0;
127
+ $item->post_id = $post_id;
128
+ if($post_id){
129
+ $post_item = get_post($post_id);
130
+ if($post_item) {
131
+ $item->slug = $post_item->post_name;
132
+ $item->post_password = $post_item->post_password;
133
+ $item->comment_count = $post_item->comment_count;
134
+ $item->comment_status = $post_item->comment_status;
135
+ }
136
+ }
137
+ } elseif('gmedia_category' == $item->taxonomy) {
138
+ $item->slug = $item->name;
139
+ $item->name = $gmGallery->options['taxonomies']['gmedia_category'][$item->slug];
140
+ }
141
+
142
+
143
+ $item = apply_filters('gmedia_term_item_more_data', $item);
144
+ }
145
+
146
+ function gmedia_terms_create_album_tpl() {
147
+ include(dirname(__FILE__) . '/tpl/album-create-item.php');
148
+ }
149
+
150
+ function gmedia_terms_create_tag_tpl() {
151
+ include(dirname(__FILE__) . '/tpl/tag-create-item.php');
152
+ }
153
+
154
+ function gmedia_terms_create_alert_tpl() {
155
+ include(dirname(__FILE__) . '/tpl/terms-create-alert.php');
156
+ }
157
+
158
+ function gmedia_term_choose_author_field($selected = false) {
159
+ global $gmCore;
160
+
161
+ $user_ID = get_current_user_id();
162
+ if(false === $selected) {
163
+ $selected = $user_ID;
164
+ }
165
+
166
+ $user_ids = gm_user_can('delete_others_media')? $gmCore->get_editable_user_ids() : array($user_ID);
167
+ if($user_ids && gm_user_can('edit_others_media')) {
168
+ if(!in_array($user_ID, $user_ids)) {
169
+ array_push($user_ids, $user_ID);
170
+ }
171
+ wp_dropdown_users(array(
172
+ 'include' => $user_ids,
173
+ 'include_selected' => true,
174
+ 'name' => 'term[global]',
175
+ 'selected' => $selected,
176
+ 'class' => 'form-control input-sm',
177
+ 'multi' => true,
178
+ 'show_option_all' => __('Shared', 'grand-media')
179
+ ));
180
+ } else {
181
+ echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
182
+ echo '<div>' . get_the_author_meta('display_name', $user_ID) . '</div>';
183
+ }
184
+ }
185
+
186
+ add_action('gmedia_term_album_after_panel', 'gmedia_term_album_after_panel');
187
+ function gmedia_term_album_after_panel($term){
188
+ include(dirname(__FILE__) . '/tpl/album-sort-gmedia.php');
189
+ }
190
+
191
+ add_action('gmedia_term_filter_after_panel', 'gmedia_term_filter_after_panel');
192
+ function gmedia_term_filter_after_panel($term){
193
+ include(dirname(__FILE__) . '/tpl/filter-preview-query.php');
194
+ }
admin/pages/taxonomy/terms.php ADDED
@@ -0,0 +1,991 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Gmedia Terms
4
+ */
5
+
6
+ // don't load directly
7
+ if(!defined('ABSPATH')) {
8
+ die('-1');
9
+ }
10
+
11
+ global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
12
+
13
+ $gmedia_url = $gmProcessor->url;
14
+ $gmedia_user_options = $gmProcessor->user_options;
15
+ $gmedia_term_taxonomy = $gmProcessor->taxonomy;
16
+
17
+ $gmedia_terms = $gmDB->get_terms($gmedia_term_taxonomy, $gmProcessor->query_args);
18
+ $gmedia_terms_count = $gmDB->count_gmedia();
19
+ $gmedia_terms_pager = $gmDB->query_pager();
20
+
21
+ ?>
22
+ <div class="panel panel-default panel-fixed-header" id="gmedia-panel">
23
+
24
+ <?php
25
+ include(dirname(__FILE__) . '/tpl/terms-panel-heading.php');
26
+
27
+ do_action('gmedia_before_terms_list');
28
+ ?>
29
+
30
+ <form class="list-group <?php echo $gmedia_term_taxonomy; ?>" id="gm-list-table" style="margin-bottom:4px;">
31
+ <?php
32
+ $taxterm = str_replace('gmedia_', '', $gmedia_term_taxonomy);
33
+ if(count($gmedia_terms)) {
34
+ foreach($gmedia_terms as &$item) {
35
+ gmedia_term_item_more_data($item);
36
+
37
+ $item->classes = array();
38
+ if('publish' != $item->status) {
39
+ if('private' == $item->status) {
40
+ $item->classes[] = 'list-group-item-info';
41
+ } elseif('draft' == $item->status) {
42
+ $item->classes[] = 'list-group-item-warning';
43
+ }
44
+ }
45
+ $item->classes[] = $item->global? (($item->global == $user_ID)? 'current_user' : 'other_user') : 'shared';
46
+ $item->selected = in_array($item->term_id, (array)$gmProcessor->selected_items);
47
+ if($item->selected) {
48
+ $item->classes[] = 'gm-selected';
49
+ }
50
+
51
+ $allow_terms_delete = gm_user_can('terms_delete');
52
+ if($item->global) {
53
+ if((int)$item->global === get_current_user_id()) {
54
+ $item->allow_edit = gm_user_can("{$taxterm}_manage");
55
+ $item->allow_delete = $allow_terms_delete;
56
+ } else {
57
+ $item->allow_edit = gm_user_can('edit_others_media');
58
+ $item->allow_delete = ($item->allow_edit && $allow_terms_delete);
59
+ }
60
+ } else {
61
+ $item->allow_edit = gm_user_can('edit_others_media');
62
+ $item->allow_delete = ($item->allow_edit && $allow_terms_delete);
63
+ }
64
+
65
+ include(dirname(__FILE__) . "/tpl/{$taxterm}-list-item.php");
66
+
67
+ }
68
+ } else {
69
+ include(dirname(__FILE__) . '/tpl/no-items.php');
70
+ }
71
+ wp_original_referer_field(true, 'previous');
72
+ wp_nonce_field('GmediaTerms');
73
+ ?>
74
+ </form>
75
+ <?php
76
+ do_action('gmedia_after_terms_list');
77
+ ?>
78
+ </div>
79
+
80
+ <?php
81
+
82
+ include(GMEDIA_ABSPATH . 'admin/tpl/modal-share.php');
83
+
84
+
85
+ /**
86
+ * gmediaAlbumEdit()
87
+ *
88
+ * @return mixed content
89
+ */
90
+ function gmediaAlbumEdit() {
91
+ global $gmDB, $gmCore, $gmProcessor, $gmGallery, $user_ID;
92
+
93
+ if(!$gmCore->caps['gmedia_album_manage']) {
94
+ die('-1');
95
+ }
96
+
97
+ $gmedia_url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
98
+
99
+ $gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
100
+ if(!is_array($gm_screen_options)) {
101
+ $gm_screen_options = array();
102
+ }
103
+ $gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
104
+
105
+ $taxonomy = $gmProcessor->taxonomy;
106
+ $term_id = $gmCore->_get('edit_item');
107
+
108
+ $term = $gmDB->get_term($term_id, $taxonomy);
109
+
110
+ if(!empty($term) && !is_wp_error($term)) {
111
+
112
+ $term_meta = $gmDB->get_metadata('gmedia_term', $term->term_id);
113
+ $term_meta = array_map('reset', $term_meta);
114
+ $term_meta = array_merge(array('_cover' => '', '_orderby' => 'ID', '_order' => 'DESC'), $term_meta);
115
+ $per_page = !empty($gm_screen_options['per_page_sort_gmedia'])? $gm_screen_options['per_page_sort_gmedia'] : 60;
116
+ $cur_page = $gmCore->_get('pager', 1);
117
+ $pager_html = '';
118
+
119
+ $termItems = array();
120
+ if($term->count) {
121
+ $args = array(
122
+ 'album__in' => $term->term_id,
123
+ 'orderby' => $term_meta['_orderby'],
124
+ 'order' => $term_meta['_order'],
125
+ 'per_page' => $per_page,
126
+ 'page' => $cur_page
127
+ );
128
+ $termItems = $gmDB->get_gmedias($args);
129
+
130
+ $pager_html = $gmDB->query_pager();
131
+ }
132
+
133
+ ?>
134
+ <div class="panel panel-default">
135
+
136
+ HEADER
137
+
138
+ EDIT FORM HERE
139
+
140
+ </div>
141
+ <div class="panel panel-default">
142
+ <div class="panel-heading clearfix">
143
+ <h4 style="margin:7px 0;" class="pull-left"><?php _e('Sort Album'); ?></h4>
144
+
145
+ <?php echo $pager_html; ?>
146
+
147
+ </div>
148
+ <form method="post" id="gmedia-sort-term" name="gmSortTerm" class="panel-body">
149
+ <div class="order-form" style="border-bottom:1px solid #ddd; margin-bottom:15px;">
150
+ <div class="row">
151
+ <div class="col-xs-3">
152
+ <div class="form-group">
153
+ <label><?php _e('Order gmedia', 'grand-media'); ?></label>
154
+ <select name="term[meta][_orderby]" id="gmedia_term_orderby" class="form-control input-sm">
155
+ <option value="custom"<?php selected($term_meta['_orderby'], 'custom'); ?>><?php _e('Custom Order', 'grand-media'); ?></option>
156
+ <option value="ID"<?php selected($term_meta['_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
157
+ <option value="title"<?php selected($term_meta['_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
158
+ <option value="gmuid"<?php selected($term_meta['_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
159
+ <option value="date"<?php selected($term_meta['_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
160
+ <option value="modified"<?php selected($term_meta['_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
161
+ <option value="rand"<?php selected($term_meta['_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
162
+ </select>
163
+ </div>
164
+ </div>
165
+ <div class="col-xs-3">
166
+ <div class="form-group">
167
+ <label><?php _e('Sort order', 'grand-media'); ?></label>
168
+ <select id="gmedia_term_order" name="term[meta][_order]" class="form-control input-sm">
169
+ <option value="DESC"<?php selected($term_meta['_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
170
+ <option value="ASC"<?php selected($term_meta['_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
171
+ </select>
172
+ </div>
173
+ </div>
174
+ <div class="col-xs-6">
175
+ <div class="form-group pull-left" style="margin-right:30px;">
176
+ <label style="visibility:hidden;">-</label>
177
+
178
+ <div class="checkbox"><label><input id="reset_order_option" type="checkbox" name="term[reset_custom_order]" value="1"> <?php _e('Reset custom order', 'grand-media'); ?> </label></div>
179
+ </div>
180
+ <div class="form-group pull-left">
181
+ <label style="visibility:hidden;">-</label>
182
+ <button style="display:block" type="submit" class="btn btn-primary btn-sm" name="gmedia_term_sort_save"><?php _e('Update', 'grand-media'); ?></button>
183
+ </div>
184
+ <?php wp_nonce_field('GmediaTerms', 'term_save_wpnonce'); ?>
185
+ <input type="hidden" name="term[term_id]" value="<?php echo $term->term_id; ?>"/>
186
+ <input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
187
+ </div>
188
+ </div>
189
+ <p><?php _e('Use your mouse (drag&drop) for custom sorting of images or manually enter index number in top right field of each image.') ?></p>
190
+ </div>
191
+ <div class="termItems clearfix" id="termItems">
192
+ <?php if(!empty($termItems)) {
193
+ foreach($termItems as $item) {
194
+ ?>
195
+ <div class="gm-img-thumbnail" data-gmid="<?php echo $item->ID; ?>"><?php
196
+ ?><img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt="<?php echo $item->ID; ?>" title="<?php echo esc_attr($item->title); ?>"/><?php
197
+ ?><input type="text" name="term[gmedia_ids][<?php echo $item->ID; ?>]" value="<?php echo isset($item->gmedia_order)? $item->gmedia_order : '0'; ?>"/><?php
198
+ ?><span class="label label-default">ID: <?php echo $item->ID; ?></span><?php
199
+ ?>
200
+ <div class="gm-img-thumb-title"><?php echo esc_html($item->title); ?></div>
201
+ </div>
202
+ <?php
203
+ }
204
+ } ?>
205
+
206
+ </div>
207
+ </form>
208
+ <div class="panel-footer clearfix" style="margin-top:20px;"><?php echo $pager_html; ?>
209
+ <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $term->count); ?></div>
210
+ </div>
211
+
212
+ <script type="text/javascript">
213
+ jQuery(function($) {
214
+ var sortdiv = $('#termItems');
215
+ var items = $('.gm-img-thumbnail', sortdiv);
216
+
217
+ sortdiv.sortable({
218
+ items: '.gm-img-thumbnail',
219
+ handle: 'img',
220
+ placeholder: 'gm-img-thumbnail ui-highlight-placeholder',
221
+ forcePlaceholderSize: true,
222
+ //revert: true,
223
+ stop: function(event, ui) {
224
+ $('#gmedia_term_orderby').val('custom');
225
+ var cur_order, prev_order, next_order;
226
+ var self = ui.item,
227
+ prev_item = self.prev(),
228
+ next_item = self.next();
229
+ prev_order = prev_item.length? parseInt($('input', prev_item).val()) : 0;
230
+ var img_order_asc = ('ASC' == $('#gmedia_term_order').val());
231
+ if(img_order_asc) {
232
+ cur_order = prev_order + 1;
233
+ $('input', self).val(cur_order);
234
+ while(next_item.length) {
235
+ next_order = parseInt(next_item.find('input').val());
236
+ if(cur_order < next_order) {
237
+ break;
238
+ }
239
+ cur_order += 1;
240
+ next_item.find('input').val(cur_order);
241
+ next_item = next_item.next();
242
+ }
243
+
244
+ } else {
245
+ next_order = next_item.length? parseInt($('input', next_item).val()) : (prev_order? (prev_order - 1) : 0);
246
+ cur_order = next_order + 1;
247
+ $('input', self).val(cur_order);
248
+ while(prev_item.length) {
249
+ prev_order = parseInt(prev_item.find('input').val());
250
+ if(cur_order < prev_order) {
251
+ break;
252
+ }
253
+ cur_order += 1;
254
+ prev_item.find('input').val(cur_order);
255
+ prev_item = prev_item.prev();
256
+ }
257
+ }
258
+ }
259
+ });
260
+
261
+ $('input', items).on('change', function() {
262
+ $('#gmedia_term_orderby').val('custom');
263
+ sortdiv.css({height: sortdiv.height()});
264
+ var items = $('.gm-img-thumbnail', sortdiv);
265
+
266
+ var new_order = $.isNumeric($(this).val())? parseInt($(this).val()) : -1;
267
+ $(this).val(new_order).closest('.gm-img-thumbnail').css({zIndex: 1000});
268
+
269
+ var ipos = [];
270
+ items.each(function(i, el) {
271
+ var pos = $(el).position();
272
+ $.data(el, 'pos', pos);
273
+ ipos[i] = pos;
274
+ });
275
+
276
+ var img_order_asc = ('ASC' == $('#gmedia_term_order').val());
277
+ var order = img_order_asc? 'asc' : 'desc';
278
+ items.tsort('input', {
279
+ useVal: true,
280
+ order: order
281
+ }, 'span.label', {order: order}).each(function(i, el) {
282
+ var from = $.data(el, 'pos');
283
+ var to = ipos[i];
284
+ $(el).css({position: 'absolute', top: from.top, left: from.left}).animate({
285
+ top: to.top,
286
+ left: to.left
287
+ }, 500);
288
+ }).promise().done(function() {
289
+ items.removeAttr('style');
290
+ sortdiv.removeAttr('style');
291
+ });
292
+
293
+ $(this).val(((0 > new_order)? 0 : new_order));
294
+ });
295
+ });
296
+ </script>
297
+
298
+ </div>
299
+
300
+
301
+ <div class="modal fade gmedia-modal" id="newCustomFieldModal" tabindex="-1" role="dialog" aria-hidden="true">
302
+ <div class="modal-dialog">
303
+ <div class="modal-content">
304
+ <div class="modal-header">
305
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
306
+ <h4 class="modal-title"><?php _e('Add New Custom Field'); ?></h4>
307
+ </div>
308
+ <form class="modal-body" method="post" id="newCustomFieldForm">
309
+ <?php
310
+ echo $gmCore->meta_form($meta_type = 'gmedia_term');
311
+ wp_nonce_field('gmedia_custom_field', '_customfield_nonce');
312
+ ?>
313
+ <input type="hidden" name="action" value="gmedia_term_add_custom_field"/>
314
+ <input type="hidden" class="newcustomfield-for-id" name="ID" value=""/>
315
+ </form>
316
+ <div class="modal-footer">
317
+ <button type="button" class="btn btn-primary customfieldsubmit"><?php _e('Add', 'grand-media'); ?></button>
318
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
319
+ </div>
320
+ </div>
321
+ </div>
322
+ </div>
323
+ <?php
324
+ } else {
325
+
326
+ }
327
+ }
328
+
329
+ /**
330
+ * gmediaFilterEdit()
331
+ *
332
+ * @return mixed content
333
+ */
334
+ function gmediaFilterEdit() {
335
+ global $gmDB, $gmCore, $gmProcessor, $gmGallery, $user_ID;
336
+
337
+ if(!$gmCore->caps['gmedia_filter_manage']) {
338
+ die('-1');
339
+ }
340
+
341
+ $gmedia_url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
342
+
343
+ /*$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
344
+ if(!is_array($gm_screen_options)){
345
+ $gm_screen_options = array();
346
+ }
347
+ $gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);*/
348
+ //$per_page = !empty($gm_screen_options['per_page_sort_gmedia'])? $gm_screen_options['per_page_sort_gmedia'] : 40;
349
+ $per_page = 40;
350
+ $cur_page = $gmCore->_get('pager', 1);
351
+
352
+ $taxonomy = $gmProcessor->taxonomy;
353
+ $term_id = (int)$gmCore->_get('edit_item');
354
+
355
+ $author_new = false;
356
+ if($gmCore->caps['gmedia_edit_others_media']) {
357
+ $author = (int)$gmCore->_get('author', $user_ID);
358
+ } else {
359
+ $author = $user_ID;
360
+ }
361
+
362
+ $pager_html = '';
363
+ $term = array(
364
+ 'name' => '',
365
+ 'description' => '',
366
+ 'global' => $author
367
+ );
368
+
369
+ $filter_data = array(
370
+ 'author__in' => array()
371
+ , 'author__not_in' => array()
372
+ , 'category__in' => array() // use category id. Same as 'cat', but does not accept negative values
373
+ , 'category__not_in' => array() // use category id. Exclude multiple categories
374
+ , 'album__in' => array() // use album id. Same as 'alb'
375
+ , 'album__not_in' => array() // use album id. Exclude multiple albums
376
+ , 'tag__and' => array() // use tag ids. Display posts that are tagged with all listed tags in array
377
+ , 'tag__in' => array() // use tag ids. To display posts from either tags listed in array. Same as 'tag'
378
+ , 'tag__not_in' => array() // use tag ids. Display posts that do not have any of the listed tag ids
379
+ , 'terms_relation' => '' // allows you to describe the boolean relationship between the taxonomy queries. Possible values are 'OR', 'AND'. Default 'AND'
380
+ , 'gmedia__in' => array() // use gmedia ids. Specify posts to retrieve
381
+ , 'gmedia__not_in' => array() // use gmedia ids. Specify post NOT to retrieve
382
+ , 'mime_type' => array() // mime types
383
+
384
+ , 'limit' => '' // (int) - set limit
385
+ , 'per_page' => '' // (int) - set limit
386
+ , 'order' => '' // Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'
387
+ , 'orderby' => '' // Sort retrieved posts by parameter. Defaults to 'ID'
388
+ , 'year' => '' // (int) - 4 digit year
389
+ , 'monthnum' => '' // (int) - Month number (from 1 to 12)
390
+ , 'day' => '' // (int) - Day of the month (from 1 to 31)
391
+
392
+ , 'meta_query' => array(
393
+ array(
394
+ 'key' => '',
395
+ 'value' => '',
396
+ 'compare' => '',
397
+ 'type' => ''
398
+ )
399
+ )
400
+ , 's' => '' // (string) - search string or terms separated by comma
401
+ , 'exact' => false // Search exactly string if 'exact' parameter set to true
402
+
403
+ );
404
+
405
+ $filter_variable_data = $term_query = array(
406
+ 'cache_results' => false,
407
+ 'page' => $cur_page, // number of page. Show the posts that would normally show up just on page X.
408
+ 'per_page' => $per_page // number of post to displace or pass over. Note: Setting offset parameter will ignore the 'page' parameter.
409
+ );
410
+
411
+ $filter_form_custom_data = array(
412
+ 'gmedia_album' => array(),
413
+ 'gmedia_category' => array(),
414
+ 'gmedia_tag' => array(),
415
+ 'gmedia_id' => array(),
416
+ 'author_id' => array(),
417
+ 'album__condition' => 'album__in',
418
+ 'category__condition' => 'category__in',
419
+ 'tag__condition' => 'tag__in',
420
+ 'gmedia_id__condition' => 'gmedia__in',
421
+ 'author_id__condition' => 'author__in'
422
+ );
423
+ /**
424
+ * @var $gmedia_album
425
+ * @var $gmedia_category
426
+ * @var $gmedia_tag
427
+ * @var $gmedia_id
428
+ * @var $author_id
429
+ * @var $album__condition
430
+ * @var $category__condition
431
+ * @var $tag__condition
432
+ * @var $gmedia_id__condition
433
+ * @var $author_id__condition
434
+ */
435
+ extract($filter_form_custom_data);
436
+
437
+ $totalResult = 0;
438
+ $trueTotalResult = 0;
439
+ if($term_id) {
440
+ $term = $gmDB->get_term($term_id, $taxonomy, ARRAY_A);
441
+ if(!empty($term) && !is_wp_error($term)) {
442
+
443
+ $term_query = $gmDB->get_metadata('gmedia_term', $term['term_id'], '_query', true);
444
+ $filter_data = array_merge($filter_data, $term_query);
445
+
446
+ $term_query = array_merge($filter_variable_data, $term_query);
447
+
448
+ if(isset($_GET['author']) && ($term['global'] != $author)) {
449
+ $filter_data['_query']['gmedia_album'] = array();
450
+ $term['global'] = $author;
451
+ $author_new = true;
452
+ }
453
+
454
+ if(!empty($filter_data['album__not_in'])) {
455
+ $album__condition = 'album__not_in';
456
+ }
457
+ $gmedia_album = $filter_data[$album__condition];
458
+
459
+ if(!empty($filter_data['category__not_in'])) {
460
+ $category__condition = 'category__not_in';
461
+ }
462
+ $gmedia_category = $filter_data[$category__condition];
463
+
464
+ if(!empty($filter_data['tag__not_in'])) {
465
+ $tag__condition = 'tag__not_in';
466
+ } elseif(!empty($filter_data['tag__and'])) {
467
+ $tag__condition = 'tag__and';
468
+ }
469
+ $gmedia_tag = $filter_data[$tag__condition];
470
+
471
+ if(!empty($filter_data['gmedia__not_in'])) {
472
+ $gmedia_id__condition = 'gmedia__not_in';
473
+ }
474
+ $gmedia_id = $filter_data[$gmedia_id__condition];
475
+
476
+ if(!empty($filter_data['author__not_in'])) {
477
+ $author_id__condition = 'author__not_in';
478
+ }
479
+ $author_id = $filter_data[$author_id__condition];
480
+
481
+ $termItems = $gmDB->get_gmedias($term_query);
482
+ $totalResult = (int)$gmDB->totalResult;
483
+ if(!$totalResult && !empty($termItems)) {
484
+ $totalResult = count($termItems);
485
+ }
486
+ if(!empty($gmDB->trueTotalResult)) {
487
+ $trueTotalResult = $gmDB->trueTotalResult;
488
+ }
489
+
490
+ if(!empty($termItems)) {
491
+ $pager_html = $gmDB->query_pager();
492
+ }
493
+ } else {
494
+ $term_id = 0;
495
+ }
496
+ }
497
+
498
+ ?>
499
+ <div class="panel panel-default">
500
+ <div class="panel-heading clearfix">
501
+ <div class="btn-toolbar pull-left">
502
+ <div class="btn-group" style="margin-right:20px;">
503
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
504
+ <?php _e('Return to') ?> <span class="caret"></span>
505
+ </button>
506
+ <ul class="dropdown-menu" role="menu">
507
+ <li><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_album'), $gmedia_url); ?>"><?php _e('Albums', 'grand-media'); ?></a></li>
508
+ <li><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_tag'), $gmedia_url); ?>"><?php _e('Tags', 'grand-media'); ?></a></li>
509
+ <li><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_category'), $gmedia_url); ?>"><?php _e('Categories', 'grand-media'); ?></a></li>
510
+ <li class="divider"></li>
511
+ <li class="active"><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_filter'), $gmedia_url); ?>"><?php _e('Custom Filters', 'grand-media'); ?></a></li>
512
+ </ul>
513
+ </div>
514
+
515
+ <?php if($term_id) { ?>
516
+ <div class="btn-group">
517
+ <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
518
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
519
+ <span class="caret"></span>
520
+ <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
521
+ </button>
522
+ <ul class="dropdown-menu" role="menu">
523
+ <li><a href="<?php echo add_query_arg(array(
524
+ 'page' => 'GrandMedia',
525
+ 'custom_filter' => $term['term_id']
526
+ ), admin_url('admin.php')); ?>"><?php _e('Show Filter in Gmedia Library', 'grand-media'); ?></a>
527
+ </li>
528
+ </ul>
529
+ </div>
530
+ <?php } ?>
531
+ </div>
532
+
533
+ </div>
534
+
535
+ <form method="post" id="gmedia-edit-term" name="gmEditTerm" class="panel-body">
536
+ <h4 style="margin-top:0;">
537
+ <?php if($term_id) { ?>
538
+ <span class="pull-right"><?php echo __('ID', 'grand-media') . ": {$term['term_id']}"; ?></span>
539
+ <?php _e('Edit Filter'); ?>: <em><?php echo esc_html($term['name']); ?></em>
540
+ <?php } else {
541
+ _e('Create Filter');
542
+ } ?>
543
+ </h4>
544
+
545
+ <div class="row">
546
+ <div class="col-xs-6">
547
+ <div class="form-group">
548
+ <label><?php _e('Filter Name', 'grand-media'); ?></label>
549
+ <input type="text" class="form-control input-sm" name="term[name]" value="<?php echo esc_attr($term['name']); ?>" placeholder="<?php _e('Filter Name', 'grand-media'); ?>" required/>
550
+ </div>
551
+ <div class="form-group pull-right">
552
+ <?php
553
+ wp_nonce_field('GmediaGallery');
554
+ wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
555
+ ?>
556
+ <input type="hidden" name="term[taxonomy]" value="gmedia_filter"/>
557
+ <input type="hidden" name="term[term_id]" value="<?php echo $term_id; ?>"/>
558
+ <button type="submit" class="btn btn-primary btn-sm" name="gmedia_filter_save"><?php _e('Save', 'grand-media'); ?></button>
559
+ </div>
560
+ <p><b><?php _e('Filter Author:', 'grand-media'); ?></b>
561
+ <?php if($gmCore->caps['gmedia_delete_others_media']) { ?>
562
+ <a href="#gallModal" data-modal="select_author" data-action="gmedia_get_modal" class="gmedia-modal" title="<?php _e('Click to choose author for gallery', 'grand-media'); ?>"><?php echo $term['global']? get_the_author_meta('display_name', $term['global']) : __('(no author / shared albums)'); ?></a>
563
+ <?php if($author_new) {
564
+ echo '<br /><span class="text-danger">' . __('Note: Author changed but not saved yet. You can see Albums list only of chosen author') . '</span>';
565
+ } ?>
566
+ <?php } else {
567
+ echo $term['global']? get_the_author_meta('display_name', $term['global']) : '&#8212;';
568
+ } ?>
569
+ <input type="hidden" name="term[global]" value="<?php echo $term['global']; ?>"/></p>
570
+
571
+ </div>
572
+ <div class="col-xs-6">
573
+ <div class="form-group">
574
+ <label><?php _e('Description', 'grand-media'); ?></label>
575
+ <textarea class="form-control input-sm" style="height:77px;" rows="2" name="term[description]"><?php echo $term['description']; ?></textarea>
576
+ </div>
577
+ </div>
578
+ </div>
579
+ <hr/>
580
+ <h4 style="margin-top:0;"><?php _e('Query Parameters'); ?></h4>
581
+
582
+ <?php if($gmCore->caps['gmedia_terms']) { ?>
583
+ <div class="form-group">
584
+ <?php
585
+ $term_type = 'gmedia_album';
586
+ $args = array();
587
+ if($term['global']) {
588
+ if(user_can($term['global'], 'gmedia_edit_others_media')) {
589
+ $args['global'] = '';
590
+ } else {
591
+ $args['global'] = array(0, $term['global']);
592
+ }
593
+ } else {
594
+ $args['global'] = 0;
595
+ }
596
+ $gm_terms = $gmDB->get_terms($term_type, $args);
597
+
598
+ $terms_items = '';
599
+ if(count($gm_terms)) {
600
+ foreach($gm_terms as $_term) {
601
+ $selected = (in_array($_term->term_id, $gmedia_album))? ' selected="selected"' : '';
602
+ $terms_items .= '<option value="' . $_term->term_id . '"' . $selected . '>' . esc_html($_term->name) . ('publish' == $_term->status? '' : " [{$_term->status}]") . ' &nbsp; (' . $_term->count . ')</option>' . "\n";
603
+ }
604
+ }
605
+ $setvalue = !empty($gmedia_album)? 'data-setvalue="' . implode(',', $gmedia_album) . '"' : '';
606
+ ?>
607
+ <label><?php _e('Choose Albums', 'grand-media'); ?> </label>
608
+
609
+ <div class="row">
610
+ <div class="col-xs-8">
611
+ <select <?php echo $setvalue; ?> id="gmedia_album" name="filter_data[gmedia_album][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Album...', 'grand-media')); ?>">
612
+ <option value=""<?php if(empty($gmedia_album)) {
613
+ echo ' selected="selected"';
614
+ } ?>><?php _e('Any Album...', 'grand-media'); ?></option>
615
+ <?php echo $terms_items; ?>
616
+ </select>
617
+ </div>
618
+ <div class="col-xs-4">
619
+ <select name="filter_data[album__condition]" class="form-control input-sm">
620
+ <option <?php selected($album__condition, 'album__in'); ?> value="album__in"><?php _e('get albums', 'grand-media'); ?></option>
621
+ <option <?php selected($album__condition, 'album__not_in'); ?> value="album__not_in"><?php _e('exclude albums', 'grand-media'); ?></option>
622
+ </select>
623
+ </div>
624
+ </div>
625
+ <p class="help-block"><?php _e('You can choose Albums from the same author as Gallery author or Albums without author', 'grand-media'); ?></p>
626
+ </div>
627
+
628
+ <div class="form-group">
629
+ <?php
630
+ $term_type = 'gmedia_category';
631
+ $gm_terms_all = $gmGallery->options['taxonomies'][$term_type];
632
+ $gm_terms = $gmDB->get_terms($term_type, array('fields' => 'names_count'));
633
+
634
+ $terms_items = '';
635
+ if(count($gm_terms)) {
636
+ foreach($gm_terms as $id => $_term) {
637
+ $selected = (in_array($id, $gmedia_category))? ' selected="selected"' : '';
638
+ $terms_items .= '<option value="' . $id . '"' . $selected . '>' . esc_html($gm_terms_all[$_term['name']]) . ' (' . $_term['count'] . ')</option>' . "\n";
639
+ }
640
+ }
641
+ $setvalue = !empty($gmedia_category)? 'data-setvalue="' . implode(',', $gmedia_category) . '"' : '';
642
+ ?>
643
+ <label><?php _e('Choose Categories', 'grand-media'); ?></label>
644
+
645
+ <div class="row">
646
+ <div class="col-xs-8">
647
+ <select <?php echo $setvalue; ?> id="gmedia_category" name="filter_data[gmedia_category][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Category...', 'grand-media')); ?>">
648
+ <option value=""<?php echo empty($gmedia_category)? ' selected="selected"' : ''; ?>><?php _e('Any Category...', 'grand-media'); ?></option>
649
+ <?php echo $terms_items; ?>
650
+ </select>
651
+ </div>
652
+ <div class="col-xs-4">
653
+ <select name="filter_data[category__condition]" class="form-control input-sm">
654
+ <option <?php selected($category__condition, 'category__in'); ?> value="category__in"><?php _e('get categories', 'grand-media'); ?></option>
655
+ <option <?php selected($category__condition, 'category__not_in'); ?> value="category__not_in"><?php _e('exclude categories', 'grand-media'); ?></option>
656
+ </select>
657
+ </div>
658
+ </div>
659
+ </div>
660
+
661
+ <div class="form-group">
662
+ <?php
663
+ $term_type = 'gmedia_tag';
664
+ $gm_terms = $gmDB->get_terms($term_type, array('fields' => 'names_count'));
665
+
666
+ $terms_items = '';
667
+ if(count($gm_terms)) {
668
+ foreach($gm_terms as $id => $_term) {
669
+ $selected = (in_array($id, $gmedia_tag))? ' selected="selected"' : '';
670
+ $terms_items .= '<option value="' . $id . '"' . $selected . '>' . esc_html($_term['name']) . ' (' . $_term['count'] . ')</option>' . "\n";
671
+ }
672
+ }
673
+ $setvalue = !empty($gmedia_tag)? 'data-setvalue="' . implode(',', $gmedia_tag) . '"' : '';
674
+ ?>
675
+ <label><?php _e('Choose Tags', 'grand-media'); ?> </label>
676
+
677
+ <div class="row">
678
+ <div class="col-xs-8">
679
+ <select <?php echo $setvalue; ?> id="gmedia_tag" name="filter_data[gmedia_tag][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Tag...', 'grand-media')); ?>">
680
+ <option value=""<?php echo empty($gmedia_tag)? ' selected="selected"' : ''; ?>><?php _e('Any Tag...', 'grand-media'); ?></option>
681
+ <?php echo $terms_items; ?>
682
+ </select>
683
+ </div>
684
+ <div class="col-xs-4">
685
+ <select name="filter_data[tag__condition]" class="form-control input-sm">
686
+ <option <?php selected($tag__condition, 'tag__in'); ?> value="tag__in"><?php _e('get items with either tags', 'grand-media'); ?></option>
687
+ <option <?php selected($tag__condition, 'tag__and'); ?> value="tag__and"><?php _e('get items that have all listed tags', 'grand-media'); ?></option>
688
+ <option <?php selected($tag__condition, 'tag__not_in'); ?> value="tag__not_in"><?php _e('exclude items that have any of the listed tags', 'grand-media'); ?></option>
689
+ </select>
690
+ </div>
691
+ </div>
692
+ </div>
693
+
694
+ <?php } ?>
695
+ <div class="form-group">
696
+ <label><?php _e('Terms Relation', 'grand-media'); ?> </label>
697
+
698
+ <div class="row">
699
+ <div class="col-xs-4">
700
+ <select name="gmedia_filter[terms_relation]" class="form-control input-sm">
701
+ <option <?php selected($filter_data['terms_relation'], ''); ?> value=""><?php _e('AND'); ?></option>
702
+ <option <?php selected($filter_data['terms_relation'], 'OR'); ?> value="OR"><?php _e('OR'); ?></option>
703
+ </select>
704
+ </div>
705
+ <div class="col-xs-8">
706
+ <p class="help-block"><?php _e('allows you to describe the relationship between the taxonomy queries', 'grand-media'); ?></p>
707
+ </div>
708
+ </div>
709
+ </div>
710
+ <div class="form-group">
711
+ <label><?php _e('Search', 'grand-media'); ?></label>
712
+
713
+ <div class="row">
714
+ <div class="col-xs-8">
715
+ <input type="text" class="form-control input-sm" placeholder="<?php _e('Search string or terms separated by comma', 'grand-media'); ?>" value="<?php echo $filter_data['s']; ?>" name="gmedia_filter[s]">
716
+ </div>
717
+ <div class="col-xs-4">
718
+ <div class="checkbox"><label><input type="checkbox" name="gmedia_filter[exact]" value="yes"<?php echo $filter_data['exact']? ' checked="checked"' : ''; ?> /> <?php _e('Search exactly string', 'grand-media'); ?></label></div>
719
+ </div>
720
+ </div>
721
+ </div>
722
+ <div class="form-group">
723
+ <div class="row">
724
+ <div class="col-xs-8">
725
+ <div class="pull-right"><a id="use_lib_selected" class="label label-primary" href="#libselected"><?php _e('Use selected in Library', 'grand-media'); ?></a></div>
726
+ <label><?php _e('Gmedia IDs <small class="text-muted">separated by comma</small>', 'grand-media'); ?> </label>
727
+ <?php $value = !empty($gmedia_id)? implode(',', wp_parse_id_list($gmedia_id)) : ''; ?>
728
+ <textarea id="gmedia__ids" name="filter_data[gmedia_id]" rows="1" class="form-control input-sm" style="resize:vertical;" placeholder="<?php echo esc_attr(__('Gmedia IDs...', 'grand-media')); ?>"><?php echo $value; ?></textarea>
729
+ </div>
730
+ <div class="col-xs-4">
731
+ <label>&nbsp;</label>
732
+ <select name="filter_data[gmedia_id__condition]" class="form-control input-sm">
733
+ <option <?php selected($gmedia_id__condition, 'gmedia__in'); ?> value="gmedia__in"><?php _e('get gmedia IDs', 'grand-media'); ?></option>
734
+ <option <?php selected($gmedia_id__condition, 'gmedia__not_in'); ?> value="gmedia__not_in"><?php _e('exclude gmedia IDs', 'grand-media'); ?></option>
735
+ </select>
736
+ </div>
737
+ </div>
738
+ <p class="help-block"><?php _e('You can select items you want to add here right in Gmedia Library and then return here and click button "Use selected in Library"', 'grand-media'); ?></p>
739
+ </div>
740
+ <div class="form-group">
741
+ <div class="row">
742
+ <div class="col-xs-4">
743
+ <label><?php _e('Mime Type', 'grand-media'); ?> </label>
744
+ <select name="gmedia_filter[mime_type][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('All types...', 'grand-media')); ?>">
745
+ <option value=""><?php _e('All types...', 'grand-media'); ?></option>
746
+ <option <?php echo in_array('image', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="image"><?php _e('Image', 'grand-media'); ?></option>
747
+ <option <?php echo in_array('audio', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="audio"><?php _e('Audio', 'grand-media'); ?></option>
748
+ <option <?php echo in_array('video', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="video"><?php _e('Video', 'grand-media'); ?></option>
749
+ <option <?php echo in_array('text', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="text"><?php _e('Text', 'grand-media'); ?></option>
750
+ <option <?php echo in_array('application', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="application"><?php _e('Application', 'grand-media'); ?></option>
751
+ </select>
752
+ </div>
753
+ <div class="col-xs-4">
754
+ <label><?php _e('Authors', 'grand-media'); ?></label>
755
+ <?php if($gmCore->caps['gmedia_show_others_media']) {
756
+ $user_ids = $gmCore->get_editable_user_ids();
757
+ if(!in_array($user_ID, $user_ids)) {
758
+ array_push($user_ids, $user_ID);
759
+ }
760
+ $filter_users = get_users(array('include' => $user_ids));
761
+ $users = '';
762
+ if(count($filter_users)) {
763
+ foreach((array)$filter_users as $user) {
764
+ $user->ID = (int)$user->ID;
765
+ $_selected = in_array($user->ID, $author_id)? ' selected="selected"' : '';
766
+ $users .= "<option value='$user->ID'$_selected>" . esc_html($user->display_name) . "</option>";
767
+ }
768
+ }
769
+ $setvalue = !empty($author_id)? 'data-setvalue="' . implode(',', $author_id) . '"' : '';
770
+ ?>
771
+ <select <?php echo $setvalue; ?> name="filter_data[author_id][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('All authors...', 'grand-media')); ?>">
772
+ <option value=""><?php _e('All authors...', 'grand-media'); ?></option>
773
+ <?php echo $users; ?>
774
+ </select>
775
+ <?php } else { ?>
776
+ <input type="text" readonly="readonly" name="filter_data[author_id][]" class="gmedia-combobox form-control input-sm" value="<?php the_author_meta('display_name', $user_ID); ?>"/>
777
+ <input type="hidden" name="filter_data[author_id__condition]" value="author__in"/>
778
+ <?php } ?>
779
+ </div>
780
+ <?php if($gmCore->caps['gmedia_show_others_media']) { ?>
781
+ <div class="col-xs-4">
782
+ <label>&nbsp;</label>
783
+ <select name="filter_data[author_id__condition]" class="form-control input-sm">
784
+ <option <?php selected($author_id__condition, 'author__in'); ?> value="author__in"><?php _e('get authors', 'grand-media'); ?></option>
785
+ <option <?php selected($author_id__condition, 'author__not_in'); ?> value="author__not_in"><?php _e('exclude authors', 'grand-media'); ?></option>
786
+ </select>
787
+ </div>
788
+ <?php } ?>
789
+ </div>
790
+ </div>
791
+ <div class="form-group">
792
+ <div class="row">
793
+ <div class="col-xs-4">
794
+ <label><?php _e('Year', 'grand-media'); ?></label>
795
+ <input type="text" class="form-control input-sm" placeholder="<?php _e('4 digit year e.g. 2011', 'grand-media'); ?>" value="<?php echo $filter_data['year']; ?>" name="gmedia_filter[year]">
796
+ </div>
797
+ <div class="col-xs-4">
798
+ <label><?php _e('Month', 'grand-media'); ?></label>
799
+ <input type="text" class="form-control input-sm" placeholder="<?php _e('from 1 to 12', 'grand-media'); ?>" value="<?php echo $filter_data['monthnum']; ?>" name="gmedia_filter[monthnum]">
800
+ </div>
801
+ <div class="col-xs-4">
802
+ <label><?php _e('Day', 'grand-media'); ?></label>
803
+ <input type="text" class="form-control input-sm" placeholder="<?php _e('from 1 to 31', 'grand-media'); ?>" value="<?php echo $filter_data['day']; ?>" name="gmedia_filter[day]">
804
+ </div>
805
+ </div>
806
+ </div>
807
+ <div class="form-group">
808
+ <?php foreach($filter_data['meta_query'] as $i => $q) {
809
+ if($i) {
810
+ continue;
811
+ }
812
+ ?>
813
+ <div class="row">
814
+ <div class="col-xs-6 col-sm-3">
815
+ <label><?php _e('Custom Field Key', 'grand-media'); ?></label>
816
+ <input type="text" class="form-control input-sm" value="<?php echo $q['key']; ?>" name="gmedia_filter[meta_query][<?php echo $i; ?>][key]">
817
+ <span class="help-block"><?php _e('Display items with this field key', 'grand-media'); ?></span>
818
+ </div>
819
+ <div class="col-xs-6 col-sm-3">
820
+ <label><?php _e('Custom Field Value', 'grand-media'); ?></label>
821
+ <input type="text" class="form-control input-sm" value="<?php echo $q['value']; ?>" name="gmedia_filter[meta_query][<?php echo $i; ?>][value]">
822
+ <span class="help-block"><?php _e('Display items with this field value', 'grand-media'); ?></span>
823
+ </div>
824
+ <div class="col-xs-6 col-sm-3">
825
+ <label><?php _e('Compare Operator', 'grand-media'); ?></label>
826
+ <select class="form-control input-sm" name="gmedia_filter[meta_query][<?php echo $i; ?>][compare]">
827
+ <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
828
+ <option <?php selected($q['compare'], '='); ?> value="=">= (<?php _e('Default', 'grand-media'); ?>)</option>
829
+ <option <?php selected($q['compare'], '!='); ?> value="!=">!=</option>
830
+ <option <?php selected($q['compare'], '>'); ?> value="&gt;">&gt;</option>
831
+ <option <?php selected($q['compare'], '>='); ?> value="&gt;=">&gt;=</option>
832
+ <option <?php selected($q['compare'], '<'); ?> value="&lt;">&lt;</option>
833
+ <option <?php selected($q['compare'], '<='); ?> value="&lt;=">&lt;=</option>
834
+ <option <?php selected($q['compare'], 'LIKE'); ?> value="LIKE">LIKE</option>
835
+ <option <?php selected($q['compare'], 'NOT LIKE'); ?> value="NOT LIKE">NOT LIKE</option>
836
+ <?php /* ?>
837
+ <option <?php selected($q['compare'], 'IN'); ?> value="IN">IN</option>
838
+ <option <?php selected($q['compare'], 'NOT IN'); ?> value="NOT IN">NOT IN</option>
839
+ <option <?php selected($q['compare'], 'BETWEEN'); ?> value="BETWEEN">BETWEEN</option>
840
+ <option <?php selected($q['compare'], 'NOT BETWEEN'); ?> value="NOT BETWEEN">NOT BETWEEN</option>
841
+ <?php */ ?>
842
+ <option <?php selected($q['compare'], 'EXISTS'); ?> value="EXISTS">EXISTS</option>
843
+ </select>
844
+ <span class="help-block"><?php _e('Operator to test the field value', 'grand-media'); ?></span>
845
+ </div>
846
+ <div class="col-xs-6 col-sm-3">
847
+ <label><?php _e('Meta Type', 'grand-media'); ?></label>
848
+ <select class="form-control input-sm" name="gmedia_filter[meta_query][<?php echo $i; ?>][type]">
849
+ <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
850
+ <option <?php selected($q['type'], 'NUMERIC'); ?> value="NUMERIC">NUMERIC</option>
851
+ <option <?php selected($q['type'], 'BINARY'); ?> value="BINARY">BINARY</option>
852
+ <option <?php selected($q['type'], 'DATE'); ?> value="DATE">DATE</option>
853
+ <option <?php selected($q['type'], 'CHAR'); ?> value="CHAR">CHAR (<?php _e('Default', 'grand-media'); ?>)</option>
854
+ <option <?php selected($q['type'], 'DATETIME'); ?> value="DATETIME">DATETIME</option>
855
+ <option <?php selected($q['type'], 'DECIMAL'); ?> value="DECIMAL">DECIMAL</option>
856
+ <option <?php selected($q['type'], 'SIGNED'); ?> value="SIGNED">SIGNED</option>
857
+ <option <?php selected($q['type'], 'TIME'); ?> value="TIME">TIME</option>
858
+ <option <?php selected($q['type'], 'UNSIGNED'); ?> value="UNSIGNED">UNSIGNED</option>
859
+ </select>
860
+ <span class="help-block"><?php _e('Custom field type', 'grand-media'); ?></span>
861
+ </div>
862
+ </div>
863
+ <?php } ?>
864
+ </div>
865
+ <div class="form-group">
866
+ <div class="row">
867
+ <div class="col-xs-6 col-sm-3">
868
+ <label><?php _e('Order', 'grand-media'); ?></label>
869
+ <select class="form-control input-sm" name="gmedia_filter[order]">
870
+ <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
871
+ <option <?php selected($filter_data['order'], 'ASC'); ?> value="ASC"><?php _e('ASC', 'grand-media'); ?></option>
872
+ <option <?php selected($filter_data['order'], 'DESC'); ?> value="DESC"><?php _e('DESC - Default', 'grand-media'); ?></option>
873
+ </select>
874
+ <span class="help-block"><?php _e('Ascending or Descending order', 'grand-media'); ?></span>
875
+ </div>
876
+ <div class="col-xs-6 col-sm-3">
877
+ <label><?php _e('Order by', 'grand-media'); ?></label>
878
+ <select class="form-control input-sm" name="gmedia_filter[orderby]">
879
+ <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
880
+ <option <?php selected($filter_data['orderby'], 'none'); ?> value="none"><?php _e('None', 'grand-media'); ?></option>
881
+ <option <?php selected($filter_data['orderby'], 'rand'); ?> value="rand"><?php _e('Random', 'grand-media'); ?></option>
882
+ <option <?php selected($filter_data['orderby'], 'id'); ?> value="id"><?php _e('ID', 'grand-media'); ?></option>
883
+ <option <?php selected($filter_data['orderby'], 'title'); ?> value="title"><?php _e('Title', 'grand-media'); ?></option>
884
+ <option <?php selected($filter_data['orderby'], 'gmuid'); ?> value="gmuid"><?php _e('Filename', 'grand-media'); ?></option>
885
+ <option <?php selected($filter_data['orderby'], 'date'); ?> value="date"><?php _e('Date - Default', 'grand-media'); ?></option>
886
+ <option <?php selected($filter_data['orderby'], 'modified'); ?> value="modified"><?php _e('Modified Date', 'grand-media'); ?></option>
887
+ <option <?php selected($filter_data['orderby'], 'author'); ?> value="author"><?php _e('Author', 'grand-media'); ?></option>
888
+ <option <?php selected($filter_data['orderby'], 'gmedia__in'); ?> value="gmedia__in"><?php _e('Selected Order', 'grand-media'); ?></option>
889
+ <option <?php selected($filter_data['orderby'], 'meta_value'); ?> value="meta_value"><?php _e('Custom Field Value', 'grand-media'); ?></option>
890
+ <option <?php selected($filter_data['orderby'], 'meta_value_num'); ?> value="meta_value_num"><?php _e('Custom Field Value (Numeric)', 'grand-media'); ?></option>
891
+ </select>
892
+ <span class="help-block"><?php _e('Sort retrieved posts by', 'grand-media'); ?></span>
893
+ </div>
894
+ <div class="col-xs-6 col-sm-3">
895
+ <label><?php _e('Limit', 'grand-media'); ?></label>
896
+ <input type="text" class="form-control input-sm" value="<?php echo $filter_data['limit']; ?>" name="gmedia_filter[limit]" placeholder="<?php _e('leave empty for no limit', 'grand-media'); ?>">
897
+ <span class="help-block"><?php _e('Limit number of gmedia items', 'grand-media'); ?></span>
898
+ </div>
899
+ <div class="col-xs-6 col-sm-3 text-right">
900
+ <label style="display:block;">&nbsp;</label>
901
+ <button type="submit" class="btn btn-primary btn-sm" name="gmedia_filter_save"><?php _e('Save', 'grand-media'); ?></button>
902
+ </div>
903
+ </div>
904
+ </div>
905
+ </form>
906
+ <script type="text/javascript">
907
+ jQuery(function($) {
908
+ <?php if($gmCore->caps['gmedia_terms']){ ?>
909
+ $('.gmedia-combobox').each(function() {
910
+ var select = $(this).selectize({
911
+ create: false,
912
+ hideSelected: true,
913
+ allowEmptyOption: true
914
+ });
915
+ var val = $(this).data('setvalue');
916
+ if(val) {
917
+ val = val.toString().split(',');
918
+ select[0].selectize.setValue(val);
919
+ }
920
+ });
921
+ <?php } ?>
922
+
923
+ $('#use_lib_selected').on('click', function() {
924
+ var field = $('#gmedia__ids');
925
+ var valData = field.val().split(',');
926
+ var storedData = getStorage('gmuser_<?php echo $user_ID; ?>_');
927
+ storedData = storedData.get('library').split(',');
928
+ valData = $.grep(valData, function(e) {
929
+ return e;
930
+ });
931
+ $.each(storedData, function(i, id) {
932
+ if(!id) {
933
+ return true;
934
+ }
935
+ if($.inArray(id, valData) === -1) {
936
+ valData.push(id);
937
+ }
938
+ });
939
+ field.val(valData.join(', '));
940
+ });
941
+ });
942
+
943
+ </script>
944
+ </div>
945
+
946
+ <div class="panel panel-default" id="queryfilter">
947
+ <div class="panel-heading clearfix">
948
+ <h4 style="margin:7px 0;" class="pull-left"><?php _e('Query Filter'); ?></h4>
949
+ <?php echo $pager_html; ?>
950
+ </div>
951
+ <div class="panel-body">
952
+ <div class="termItems clearfix">
953
+ <?php if(!empty($termItems)) {
954
+ foreach($termItems as $item) {
955
+ $item_class = '';
956
+ ?>
957
+ <div class="gm-img-thumbnail<?php echo $item_class; ?>" data-gmid="<?php echo $item->ID; ?>"><?php
958
+ ?><img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt="<?php echo $item->ID; ?>" title="<?php echo esc_attr($item->title); ?>"/><?php
959
+ ?><span class="label label-default">ID: <?php echo $item->ID; ?></span><?php
960
+ ?>
961
+ <div class="gm-img-thumb-title"><?php echo esc_html($item->title); ?></div>
962
+ </div>
963
+ <?php
964
+ }
965
+ } else {
966
+ if($term_id) { ?>
967
+ <p class="text-center"><?php _e('No items with selected parameters.') ?></p>
968
+ <?php } else { ?>
969
+ <p class="text-center"><?php _e('Set Filter parameters and click Save button to test query.') ?></p>
970
+ <?php }
971
+ } ?>
972
+ </div>
973
+ </div>
974
+ <div class="panel-footer clearfix" style="margin-top:20px;"><?php echo $pager_html; ?>
975
+ <?php if($trueTotalResult) { ?>
976
+ <div class="well well-sm pull-left" style="margin-right:10px;"><?php printf(__('Limited to: %d'), $totalResult); ?></div>
977
+ <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $trueTotalResult); ?></div>
978
+ <?php } else { ?>
979
+ <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $totalResult); ?></div>
980
+ <?php } ?>
981
+ </div>
982
+ </div>
983
+
984
+ <?php if($gmCore->caps['gmedia_edit_others_media']) { ?>
985
+ <div class="modal fade gmedia-modal" id="gallModal" tabindex="-1" role="dialog" aria-hidden="true">
986
+ <div class="modal-dialog"></div>
987
+ </div>
988
+ <?php } ?>
989
+
990
+ <?php
991
+ }
admin/pages/taxonomy/tpl/album-create-item.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add Album Form
4
+ */
5
+ global $gmProcessor, $gmGallery;
6
+ $gmedia_url = $gmProcessor->url;
7
+ ?>
8
+ <form method="post" id="gmedia-edit-term" name="gmAddTerms" class="panel-body" action="<?php echo $gmedia_url; ?>" style="padding-bottom:0; border-bottom:1px solid #ddd;">
9
+ <div class="row">
10
+ <div class="col-xs-6">
11
+ <div class="form-group">
12
+ <label><?php _e('Name', 'grand-media'); ?></label>
13
+ <input type="text" class="form-control input-sm" name="term[name]" placeholder="<?php _e('Album Name', 'grand-media'); ?>" required/>
14
+ </div>
15
+ <div class="form-group">
16
+ <label><?php _e('Description', 'grand-media'); ?></label>
17
+ <textarea class="form-control input-sm" style="height:98px;" rows="2" name="term[description]"></textarea>
18
+ </div>
19
+ </div>
20
+ <div class="col-xs-6">
21
+ <div class="form-group row">
22
+ <div class="col-xs-6">
23
+ <label><?php _e('Order gmedia', 'grand-media'); ?></label>
24
+ <select name="term[meta][_orderby]" class="form-control input-sm">
25
+ <option value="custom"><?php _e('user defined', 'grand-media'); ?></option>
26
+ <option selected="selected" value="ID"><?php _e('by ID', 'grand-media'); ?></option>
27
+ <option value="title"><?php _e('by title', 'grand-media'); ?></option>
28
+ <option value="gmuid"><?php _e('by filename', 'grand-media'); ?></option>
29
+ <option value="date"><?php _e('by date', 'grand-media'); ?></option>
30
+ <option value="modified"><?php _e('by last modified date', 'grand-media'); ?></option>
31
+ <option value="rand"><?php _e('Random', 'grand-media'); ?></option>
32
+ </select>
33
+ </div>
34
+ <div class="col-xs-6">
35
+ <label><?php _e('Sort order', 'grand-media'); ?></label>
36
+ <select name="term[meta][_order]" class="form-control input-sm">
37
+ <option selected="selected" value="DESC"><?php _e('DESC', 'grand-media'); ?></option>
38
+ <option value="ASC"><?php _e('ASC', 'grand-media'); ?></option>
39
+ </select>
40
+ </div>
41
+ </div>
42
+ <div class="row">
43
+ <div class="col-xs-6">
44
+ <div class="form-group">
45
+ <label><?php _e('Status', 'grand-media'); ?></label>
46
+ <select name="term[status]" class="form-control input-sm">
47
+ <option selected="selected" value="publish"><?php _e('Public', 'grand-media'); ?></option>
48
+ <option value="private"><?php _e('Private', 'grand-media'); ?></option>
49
+ <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
50
+ </select>
51
+ </div>
52
+ <?php /* ?>
53
+ <div class="form-group">
54
+ <label><?php _e('Comment Status', 'grand-media'); ?></label>
55
+ <select name="term[comment_status]" class="form-control input-sm">
56
+ <option <?php echo ('open' == $gmGallery->options['default_gmedia_term_comment_status'])? 'selected="selected"' : ''; ?> value="open"><?php _e('Open', 'grand-media'); ?></option>
57
+ <option <?php echo ('closed' == $gmGallery->options['default_gmedia_term_comment_status'])? 'selected="selected"' : ''; ?> value="closed"><?php _e('Closed', 'grand-media'); ?></option>
58
+ </select>
59
+ </div>
60
+ <?php */ ?>
61
+ </div>
62
+ <div class="col-xs-6">
63
+ <div class="form-group">
64
+ <label><?php _e('Author', 'grand-media'); ?></label>
65
+ <?php gmedia_term_choose_author_field(); ?>
66
+ </div>
67
+ <div class="form-group">
68
+ <label>&nbsp;</label>
69
+ <?php
70
+ wp_original_referer_field(true, 'previous');
71
+ wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
72
+ ?>
73
+ <input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
74
+ <button style="display:block" type="submit" class="btn btn-primary btn-sm" name="gmedia_album_save"><?php _e('Add New Album', 'grand-media'); ?></button>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </form>
admin/pages/taxonomy/tpl/album-edit-item.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Edit Album Form
4
+ */
5
+ ?>
6
+ <form method="post" id="gmedia-edit-term" name="gmEditTerm" class="panel-body" data-id="<?php echo $term->term_id; ?>">
7
+ <h4 style="margin-top:0;">
8
+ <span class="pull-right"><?php echo __('ID', 'grand-media') . ": {$term->term_id}"; ?></span>
9
+ <?php _e('Edit Album'); ?>: <em><?php echo esc_html($term->name); ?></em>
10
+ </h4>
11
+
12
+ <div class="row">
13
+ <div class="col-xs-6">
14
+ <div class="form-group">
15
+ <label><?php _e('Name', 'grand-media'); ?></label>
16
+ <input type="text" class="form-control input-sm" name="term[name]" value="<?php echo esc_attr($term->name); ?>" placeholder="<?php _e('Album Name', 'grand-media'); ?>" required/>
17
+ </div>
18
+ <div class="form-group">
19
+ <label><?php _e('Description', 'grand-media'); ?></label>
20
+ <textarea class="form-control input-sm" style="height:128px;" rows="2" name="term[description]"><?php echo $term->description; ?></textarea>
21
+ </div>
22
+ <div class="text-right">
23
+ <?php wp_nonce_field('GmediaTerms', 'term_save_wpnonce'); ?>
24
+ <input type="hidden" name="term[term_id]" value="<?php echo $term->term_id; ?>"/>
25
+ <input type="hidden" name="term[taxonomy]" value="<?php echo $term->taxonomy; ?>"/>
26
+ <button type="submit" class="btn btn-primary btn-sm" name="gmedia_album_save"><?php _e('Update', 'grand-media'); ?></button>
27
+ </div>
28
+ </div>
29
+ <div class="col-xs-6">
30
+ <div class="row">
31
+ <div class="col-xs-6">
32
+ <div class="form-group">
33
+ <label><?php _e('Author', 'grand-media'); ?></label>
34
+ <?php gmedia_term_choose_author_field($term->global); ?>
35
+ </div>
36
+ <div class="form-group">
37
+ <label><?php _e('Status', 'grand-media'); ?></label>
38
+ <select name="term[status]" class="form-control input-sm">
39
+ <option value="publish"<?php selected($term->status, 'publish'); ?>><?php _e('Public', 'grand-media'); ?></option>
40
+ <option value="private"<?php selected($term->status, 'private'); ?>><?php _e('Private', 'grand-media'); ?></option>
41
+ <option value="draft"<?php selected($term->status, 'draft'); ?>><?php _e('Draft', 'grand-media'); ?></option>
42
+ </select>
43
+ <div class="cb-help-block">
44
+ <div class="checkbox"><label><input type="checkbox" name="term[status_global]" value="1"> <?php _e('Apply Status for all items in album', 'grand-media'); ?> </label></div>
45
+ </div>
46
+ </div>
47
+ <?php /*if(isset($term->comment_status)){ ?>
48
+ <div class="form-group">
49
+ <a href="<?php echo admin_url("admin.php?page=GrandMedia&gmediablank=comments&gmedia_term_id={$term->term_id}"); ?>" data-target="#previewModal" data-width="900" data-height="500" class="preview-modal gmpost-com-count pull-right" title="<?php esc_attr_e('Comments', 'grand-media'); ?>">
50
+ <b class="comment-count"><?php echo $term->comment_count; ?></b>
51
+ <span class="glyphicon glyphicon-comment"></span>
52
+ </a>
53
+ <label><?php _e('Comment Status', 'grand-media'); ?></label>
54
+ <select name="term[comment_status]" class="form-control input-sm">
55
+ <option value="open"<?php selected($term->comment_status, 'open'); ?>><?php _e('Open', 'grand-media'); ?></option>
56
+ <option value="closed"<?php selected($term->comment_status, 'closed'); ?>><?php _e('Closed', 'grand-media'); ?></option>
57
+ </select>
58
+ </div>
59
+ <?php }*/ ?>
60
+ </div>
61
+ <div class="col-xs-6">
62
+ <?php if(isset($term->slug)){ ?>
63
+ <div class="form-group">
64
+ <label><?php _e('Slug', 'grand-media'); ?></label>
65
+ <input type="text" class="form-control input-sm" name="term[slug]" value="<?php echo esc_attr($term->slug); ?>"/>
66
+ </div>
67
+ <?php } ?>
68
+ <?php $cover_id = isset($term->meta['_cover'][0])? $term->meta['_cover'][0] : ''; ?>
69
+ <div class="form-group">
70
+ <label><?php _e('Album Cover', 'grand-media'); ?></label>
71
+ <input type="text" class="form-control input-sm" name="term[meta][_cover]" value="<?php echo esc_attr($cover_id); ?>" placeholder="<?php _e('Gmedia Image ID', 'grand-media'); ?>"/>
72
+ </div>
73
+ <?php
74
+ if(($cover_id = intval($cover_id))) {
75
+ if(($cover = $gmDB->get_gmedia($cover_id))) { ?>
76
+ <div class="gm-img-thumbnail" data-gmid="<?php echo $cover->ID; ?>"><?php
77
+ ?><img src="<?php echo $gmCore->gm_get_media_image($cover, 'thumb', true); ?>" alt="<?php echo $cover->ID; ?>" title="<?php echo esc_attr($cover->title); ?>"/><?php
78
+ ?><span class="label label-default">ID: <?php echo $cover->ID; ?></span><?php
79
+ ?></div>
80
+ <?php } else {
81
+ echo '<strong class="text-danger">' . __('No image with such ID', 'grand-media') . '</strong>';
82
+ }
83
+ }
84
+ ?>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ <hr/>
90
+ <?php
91
+ $gmCore->gmedia_custom_meta_box($term->term_id, $meta_type = 'gmedia_term');
92
+ do_action('gmedia_term_edit_form');
93
+ ?>
94
+ </form>
95
+
96
+ <div class="modal fade gmedia-modal" id="newCustomFieldModal" tabindex="-1" role="dialog" aria-hidden="true">
97
+ <div class="modal-dialog">
98
+ <div class="modal-content">
99
+ <div class="modal-header">
100
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
101
+ <h4 class="modal-title"><?php _e('Add New Custom Field'); ?></h4>
102
+ </div>
103
+ <form class="modal-body" method="post" id="newCustomFieldForm">
104
+ <?php
105
+ echo $gmCore->meta_form($meta_type = 'gmedia_term');
106
+ wp_nonce_field('gmedia_custom_field', '_customfield_nonce');
107
+ ?>
108
+ <input type="hidden" name="action" value="gmedia_term_add_custom_field"/>
109
+ <input type="hidden" class="newcustomfield-for-id" name="ID" value=""/>
110
+ </form>
111
+ <div class="modal-footer">
112
+ <button type="button" class="btn btn-primary customfieldsubmit"><?php _e('Add', 'grand-media'); ?></button>
113
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
114
+ </div>
115
+ </div>
116
+ </div>
117
+ </div>
118
+
119
+ <div class="modal fade gmedia-modal" id="previewModal" tabindex="-1" role="dialog" aria-hidden="true">
120
+ <div class="modal-dialog">
121
+ <div class="modal-content">
122
+ <div class="modal-header">
123
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
124
+ <h4 class="modal-title"></h4>
125
+ </div>
126
+ <div class="modal-body"></div>
127
+ </div>
128
+ </div>
129
+ </div>
admin/pages/taxonomy/tpl/album-list-item.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Album list item
4
+ *
5
+ * @var $item
6
+ * @var $gmedia_url
7
+ */
8
+ ?>
9
+ <div class="cb_list-item list-group-item term-list-item <?php echo implode(' ', $item->classes); ?>">
10
+ <div class="row cb_term-object">
11
+ <div class="term_id">#<?php echo $item->term_id; ?></div>
12
+ <div class="col-xs-6 term-label">
13
+ <div class="checkbox">
14
+ <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> value="<?php echo $item->term_id; ?>"/>
15
+ <?php if($item->allow_edit) { ?>
16
+ <a class="term_name" href="<?php echo add_query_arg(array('edit_item' => $item->term_id), $gmedia_url); ?>"><?php echo esc_html($item->name); ?></a>
17
+ <?php } else { ?>
18
+ <span class="term_name"><?php echo esc_html($item->name); ?></span>
19
+ <?php } ?>
20
+ <span class="term_info_author"><?php
21
+ if($item->global) {
22
+ echo $item->author_name? sprintf(__('by %s', 'grand-media'), $item->author_name) : '(' . __('deleted author', 'grand-media') . ')';
23
+ } else {
24
+ echo '(' . __('no author', 'grand-media') . ')';
25
+ }
26
+ ?></span>
27
+
28
+ <div class="object-actions">
29
+ <?php $action_links = gmedia_term_item_actions($item);
30
+ echo implode('', $action_links);
31
+ ?>
32
+ </div>
33
+ <?php if(!empty($item->description)) { ?>
34
+ <div class="term-description"><?php echo esc_html(nl2br($item->description)); ?></div>
35
+ <?php } ?>
36
+ </div>
37
+ </div>
38
+ <div class="col-xs-6">
39
+ <?php gmedia_term_item_thumbnails($item); ?>
40
+ </div>
41
+ </div>
42
+ </div>
43
+
admin/pages/taxonomy/tpl/album-sort-gmedia.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sort Gmedia in Album
4
+ *
5
+ * @var $term
6
+ */
7
+ if(!$term->count) {
8
+ return;
9
+ }
10
+
11
+ global $gmDB, $gmCore;
12
+
13
+ $_orderby = isset($term->meta['_orderby'][0])? $term->meta['_orderby'][0] : '';
14
+ $_order = isset($term->meta['_order'][0])? $term->meta['_order'][0] : '';
15
+ $per_page = !empty($gmedia_user_options['per_page_sort_gmedia'])? $gmedia_user_options['per_page_sort_gmedia'] : 60;
16
+ $cur_page = $gmCore->_get('pager', 1);
17
+
18
+ $args = array(
19
+ 'album__in' => $term->term_id,
20
+ 'orderby' => $_orderby,
21
+ 'order' => $_order,
22
+ 'per_page' => $per_page,
23
+ 'page' => $cur_page
24
+ );
25
+
26
+ $termItems = $gmDB->get_gmedias($args);
27
+ $pager_html = $gmDB->query_pager();
28
+
29
+
30
+ ?>
31
+ <div class="panel panel-default">
32
+ <div class="panel-heading clearfix">
33
+ <h4 style="margin:7px 0;" class="pull-left"><?php _e('Sort Album'); ?></h4>
34
+
35
+ <?php echo $pager_html; ?>
36
+
37
+ </div>
38
+ <form method="post" id="gmedia-sort-term" name="gmSortTerm" class="panel-body">
39
+ <div class="order-form" style="border-bottom:1px solid #ddd; margin-bottom:15px;">
40
+ <div class="row">
41
+ <div class="col-xs-3">
42
+ <div class="form-group">
43
+ <label><?php _e('Order gmedia', 'grand-media'); ?></label>
44
+ <select name="term[meta][_orderby]" id="gmedia_term_orderby" class="form-control input-sm">
45
+ <option value="custom"<?php selected($_orderby, 'custom'); ?>><?php _e('Custom Order', 'grand-media'); ?></option>
46
+ <option value="ID"<?php selected($_orderby, 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
47
+ <option value="title"<?php selected($_orderby, 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
48
+ <option value="gmuid"<?php selected($_orderby, 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
49
+ <option value="date"<?php selected($_orderby, 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
50
+ <option value="modified"<?php selected($_orderby, 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
51
+ <option value="rand"<?php selected($_orderby, 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
52
+ </select>
53
+ </div>
54
+ </div>
55
+ <div class="col-xs-3">
56
+ <div class="form-group">
57
+ <label><?php _e('Sort order', 'grand-media'); ?></label>
58
+ <select id="gmedia_term_order" name="term[meta][_order]" class="form-control input-sm">
59
+ <option value="DESC"<?php selected($_order, 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
60
+ <option value="ASC"<?php selected($_order, 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
61
+ </select>
62
+ </div>
63
+ </div>
64
+ <div class="col-xs-6">
65
+ <div class="form-group pull-left" style="margin-right:30px;">
66
+ <label style="visibility:hidden;">-</label>
67
+
68
+ <div class="checkbox"><label><input id="reset_order_option" type="checkbox" name="term[reset_custom_order]" value="1"> <?php _e('Reset custom order', 'grand-media'); ?> </label></div>
69
+ </div>
70
+ <div class="form-group pull-left">
71
+ <label style="visibility:hidden;">-</label>
72
+ <button style="display:block" type="submit" class="btn btn-primary btn-sm" name="gmedia_term_sort_save"><?php _e('Update', 'grand-media'); ?></button>
73
+ </div>
74
+ <?php wp_nonce_field('GmediaTerms', 'term_save_wpnonce'); ?>
75
+ <input type="hidden" name="term[term_id]" value="<?php echo $term->term_id; ?>"/>
76
+ <input type="hidden" name="term[taxonomy]" value="<?php echo $term->taxonomy; ?>"/>
77
+ </div>
78
+ </div>
79
+ <p><?php _e('Use your mouse (drag&drop) for custom sorting of images or manually enter index number in top right field of each image.') ?></p>
80
+ </div>
81
+ <div class="termItems clearfix" id="termItems">
82
+ <?php if(!empty($termItems)) {
83
+ foreach($termItems as $item) {
84
+ ?>
85
+ <div class="gm-img-thumbnail" data-gmid="<?php echo $item->ID; ?>"><?php
86
+ ?><img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt="<?php echo $item->ID; ?>" title="<?php echo esc_attr($item->title); ?>"/><?php
87
+ ?><input type="text" name="term[gmedia_ids][<?php echo $item->ID; ?>]" value="<?php echo isset($item->gmedia_order)? $item->gmedia_order : '0'; ?>"/><?php
88
+ ?><span class="label label-default">ID: <?php echo $item->ID; ?></span><?php
89
+ ?>
90
+ <div class="gm-img-thumb-title"><?php echo esc_html($item->title); ?></div>
91
+ </div>
92
+ <?php
93
+ }
94
+ } ?>
95
+
96
+ </div>
97
+ </form>
98
+ <div class="panel-footer clearfix" style="margin-top:20px;"><?php echo $pager_html; ?>
99
+ <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $term->count); ?></div>
100
+ </div>
101
+
102
+ <script type="text/javascript">
103
+ jQuery(function($) {
104
+ var sortdiv = $('#termItems');
105
+ var items = $('.gm-img-thumbnail', sortdiv);
106
+
107
+ sortdiv.sortable({
108
+ items: '.gm-img-thumbnail',
109
+ handle: 'img',
110
+ placeholder: 'gm-img-thumbnail ui-highlight-placeholder',
111
+ forcePlaceholderSize: true,
112
+ //revert: true,
113
+ stop: function(event, ui) {
114
+ $('#gmedia_term_orderby').val('custom');
115
+ var cur_order, prev_order, next_order;
116
+ var self = ui.item,
117
+ prev_item = self.prev(),
118
+ next_item = self.next();
119
+ prev_order = prev_item.length? parseInt($('input', prev_item).val()) : 0;
120
+ var img_order_asc = ('ASC' == $('#gmedia_term_order').val());
121
+ if(img_order_asc) {
122
+ cur_order = prev_order + 1;
123
+ $('input', self).val(cur_order);
124
+ while(next_item.length) {
125
+ next_order = parseInt(next_item.find('input').val());
126
+ if(cur_order < next_order) {
127
+ break;
128
+ }
129
+ cur_order += 1;
130
+ next_item.find('input').val(cur_order);
131
+ next_item = next_item.next();
132
+ }
133
+
134
+ } else {
135
+ next_order = next_item.length? parseInt($('input', next_item).val()) : (prev_order? (prev_order - 1) : 0);
136
+ cur_order = next_order + 1;
137
+ $('input', self).val(cur_order);
138
+ while(prev_item.length) {
139
+ prev_order = parseInt(prev_item.find('input').val());
140
+ if(cur_order < prev_order) {
141
+ break;
142
+ }
143
+ cur_order += 1;
144
+ prev_item.find('input').val(cur_order);
145
+ prev_item = prev_item.prev();
146
+ }
147
+ }
148
+ }
149
+ });
150
+
151
+ $('input', items).on('change', function() {
152
+ $('#gmedia_term_orderby').val('custom');
153
+ sortdiv.css({height: sortdiv.height()});
154
+ var items = $('.gm-img-thumbnail', sortdiv);
155
+
156
+ var new_order = $.isNumeric($(this).val())? parseInt($(this).val()) : -1;
157
+ $(this).val(new_order).closest('.gm-img-thumbnail').css({zIndex: 1000});
158
+
159
+ var ipos = [];
160
+ items.each(function(i, el) {
161
+ var pos = $(el).position();
162
+ $.data(el, 'pos', pos);
163
+ ipos[i] = pos;
164
+ });
165
+
166
+ var img_order_asc = ('ASC' == $('#gmedia_term_order').val());
167
+ var order = img_order_asc? 'asc' : 'desc';
168
+ items.tsort('input', {
169
+ useVal: true,
170
+ order: order
171
+ }, 'span.label', {order: order}).each(function(i, el) {
172
+ var from = $.data(el, 'pos');
173
+ var to = ipos[i];
174
+ $(el).css({position: 'absolute', top: from.top, left: from.left}).animate({
175
+ top: to.top,
176
+ left: to.left
177
+ }, 500);
178
+ }).promise().done(function() {
179
+ items.removeAttr('style');
180
+ sortdiv.removeAttr('style');
181
+ });
182
+
183
+ $(this).val(((0 > new_order)? 0 : new_order));
184
+ });
185
+ });
186
+ </script>
187
+
188
+ </div>
admin/pages/taxonomy/tpl/category-list-item.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Category list item
4
+ *
5
+ * @var $item
6
+ */
7
+ ?>
8
+ <div class="list-group-item term-list-item">
9
+ <div class="row cb_term-object">
10
+ <div class="term_id">#<?php echo $item->term_id; ?></div>
11
+ <div class="col-xs-6 term-label" style="padding-top:10px; padding-bottom:10px;">
12
+ <span class="term_name"><?php echo esc_html($item->name); ?></span>
13
+ <div class="object-actions">
14
+ <?php $action_links = gmedia_term_item_actions($item);
15
+ echo implode('', $action_links);
16
+ ?>
17
+ </div>
18
+ </div>
19
+ <div class="col-xs-6">
20
+ <?php gmedia_term_item_thumbnails($item); ?>
21
+ </div>
22
+ </div>
23
+ </div>
admin/pages/taxonomy/tpl/filter-edit-item.php ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Edit Filter Form
4
+ */
5
+ ?>
6
+ <form method="post" id="gmedia-edit-term" name="gmEditTerm" class="panel-body">
7
+ <h4 style="margin-top:0;">
8
+ <?php if($term_id) { ?>
9
+ <span class="pull-right"><?php echo __('ID', 'grand-media') . ": {$term['term_id']}"; ?></span>
10
+ <?php _e('Edit Filter'); ?>: <em><?php echo esc_html($term['name']); ?></em>
11
+ <?php } else {
12
+ _e('Create Filter');
13
+ } ?>
14
+ </h4>
15
+
16
+ <div class="row">
17
+ <div class="col-xs-6">
18
+ <div class="form-group">
19
+ <label><?php _e('Filter Name', 'grand-media'); ?></label>
20
+ <input type="text" class="form-control input-sm" name="term[name]" value="<?php echo esc_attr($term['name']); ?>" placeholder="<?php _e('Filter Name', 'grand-media'); ?>" required/>
21
+ </div>
22
+ <div class="form-group pull-right">
23
+ <?php
24
+ wp_nonce_field('GmediaGallery');
25
+ wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
26
+ ?>
27
+ <input type="hidden" name="term[taxonomy]" value="gmedia_filter"/>
28
+ <input type="hidden" name="term[term_id]" value="<?php echo $term_id; ?>"/>
29
+ <button type="submit" class="btn btn-primary btn-sm" name="gmedia_filter_save"><?php _e('Save', 'grand-media'); ?></button>
30
+ </div>
31
+ <p><b><?php _e('Filter Author:', 'grand-media'); ?></b>
32
+ <?php if(gm_user_can('delete_others_media')) { ?>
33
+ <a href="#gallModal" data-modal="select_author" data-action="gmedia_get_modal" class="gmedia-modal" title="<?php _e('Click to choose author for gallery', 'grand-media'); ?>"><?php echo $term['global']? get_the_author_meta('display_name', $term['global']) : __('(no author / shared albums)'); ?></a>
34
+ <?php if($author_new) {
35
+ echo '<br /><span class="text-danger">' . __('Note: Author changed but not saved yet. You can see Albums list only of chosen author') . '</span>';
36
+ } ?>
37
+ <?php } else {
38
+ echo $term['global']? get_the_author_meta('display_name', $term['global']) : '&#8212;';
39
+ } ?>
40
+ <input type="hidden" name="term[global]" value="<?php echo $term['global']; ?>"/></p>
41
+
42
+ </div>
43
+ <div class="col-xs-6">
44
+ <div class="form-group">
45
+ <label><?php _e('Description', 'grand-media'); ?></label>
46
+ <textarea class="form-control input-sm" style="height:77px;" rows="2" name="term[description]"><?php echo $term['description']; ?></textarea>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ <hr/>
51
+ <h4 style="margin-top:0;"><?php _e('Query Parameters'); ?></h4>
52
+
53
+ <?php if(gm_user_can('terms')) { ?>
54
+ <div class="form-group">
55
+ <?php
56
+ $term_type = 'gmedia_album';
57
+ $args = array();
58
+ if($term['global']) {
59
+ if(user_can($term['global'], 'gmedia_edit_others_media')) {
60
+ $args['global'] = '';
61
+ } else {
62
+ $args['global'] = array(0, $term['global']);
63
+ }
64
+ } else {
65
+ $args['global'] = 0;
66
+ }
67
+ $gm_terms = $gmDB->get_terms($term_type, $args);
68
+
69
+ $terms_items = '';
70
+ if(count($gm_terms)) {
71
+ foreach($gm_terms as $_term) {
72
+ $selected = (in_array($_term->term_id, $gmedia_album))? ' selected="selected"' : '';
73
+ $terms_items .= '<option value="' . $_term->term_id . '"' . $selected . '>' . esc_html($_term->name) . ('publish' == $_term->status? '' : " [{$_term->status}]") . ' &nbsp; (' . $_term->count . ')</option>' . "\n";
74
+ }
75
+ }
76
+ $setvalue = !empty($gmedia_album)? 'data-setvalue="' . implode(',', $gmedia_album) . '"' : '';
77
+ ?>
78
+ <label><?php _e('Choose Albums', 'grand-media'); ?> </label>
79
+
80
+ <div class="row">
81
+ <div class="col-xs-8">
82
+ <select <?php echo $setvalue; ?> id="gmedia_album" name="filter_data[gmedia_album][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Album...', 'grand-media')); ?>">
83
+ <option value=""<?php if(empty($gmedia_album)) {
84
+ echo ' selected="selected"';
85
+ } ?>><?php _e('Any Album...', 'grand-media'); ?></option>
86
+ <?php echo $terms_items; ?>
87
+ </select>
88
+ </div>
89
+ <div class="col-xs-4">
90
+ <select name="filter_data[album__condition]" class="form-control input-sm">
91
+ <option <?php selected($album__condition, 'album__in'); ?> value="album__in"><?php _e('get albums', 'grand-media'); ?></option>
92
+ <option <?php selected($album__condition, 'album__not_in'); ?> value="album__not_in"><?php _e('exclude albums', 'grand-media'); ?></option>
93
+ </select>
94
+ </div>
95
+ </div>
96
+ <p class="help-block"><?php _e('You can choose Albums from the same author as Gallery author or Albums without author', 'grand-media'); ?></p>
97
+ </div>
98
+
99
+ <div class="form-group">
100
+ <?php
101
+ $term_type = 'gmedia_category';
102
+ $gm_terms_all = $gmGallery->options['taxonomies'][$term_type];
103
+ $gm_terms = $gmDB->get_terms($term_type, array('fields' => 'names_count'));
104
+
105
+ $terms_items = '';
106
+ if(count($gm_terms)) {
107
+ foreach($gm_terms as $id => $_term) {
108
+ $selected = (in_array($id, $gmedia_category))? ' selected="selected"' : '';
109
+ $terms_items .= '<option value="' . $id . '"' . $selected . '>' . esc_html($gm_terms_all[$_term['name']]) . ' (' . $_term['count'] . ')</option>' . "\n";
110
+ }
111
+ }
112
+ $setvalue = !empty($gmedia_category)? 'data-setvalue="' . implode(',', $gmedia_category) . '"' : '';
113
+ ?>
114
+ <label><?php _e('Choose Categories', 'grand-media'); ?></label>
115
+
116
+ <div class="row">
117
+ <div class="col-xs-8">
118
+ <select <?php echo $setvalue; ?> id="gmedia_category" name="filter_data[gmedia_category][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Category...', 'grand-media')); ?>">
119
+ <option value=""<?php echo empty($gmedia_category)? ' selected="selected"' : ''; ?>><?php _e('Any Category...', 'grand-media'); ?></option>
120
+ <?php echo $terms_items; ?>
121
+ </select>
122
+ </div>
123
+ <div class="col-xs-4">
124
+ <select name="filter_data[category__condition]" class="form-control input-sm">
125
+ <option <?php selected($category__condition, 'category__in'); ?> value="category__in"><?php _e('get categories', 'grand-media'); ?></option>
126
+ <option <?php selected($category__condition, 'category__not_in'); ?> value="category__not_in"><?php _e('exclude categories', 'grand-media'); ?></option>
127
+ </select>
128
+ </div>
129
+ </div>
130
+ </div>
131
+
132
+ <div class="form-group">
133
+ <?php
134
+ $term_type = 'gmedia_tag';
135
+ $gm_terms = $gmDB->get_terms($term_type, array('fields' => 'names_count'));
136
+
137
+ $terms_items = '';
138
+ if(count($gm_terms)) {
139
+ foreach($gm_terms as $id => $_term) {
140
+ $selected = (in_array($id, $gmedia_tag))? ' selected="selected"' : '';
141
+ $terms_items .= '<option value="' . $id . '"' . $selected . '>' . esc_html($_term['name']) . ' (' . $_term['count'] . ')</option>' . "\n";
142
+ }
143
+ }
144
+ $setvalue = !empty($gmedia_tag)? 'data-setvalue="' . implode(',', $gmedia_tag) . '"' : '';
145
+ ?>
146
+ <label><?php _e('Choose Tags', 'grand-media'); ?> </label>
147
+
148
+ <div class="row">
149
+ <div class="col-xs-8">
150
+ <select <?php echo $setvalue; ?> id="gmedia_tag" name="filter_data[gmedia_tag][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Tag...', 'grand-media')); ?>">
151
+ <option value=""<?php echo empty($gmedia_tag)? ' selected="selected"' : ''; ?>><?php _e('Any Tag...', 'grand-media'); ?></option>
152
+ <?php echo $terms_items; ?>
153
+ </select>
154
+ </div>
155
+ <div class="col-xs-4">
156
+ <select name="filter_data[tag__condition]" class="form-control input-sm">
157
+ <option <?php selected($tag__condition, 'tag__in'); ?> value="tag__in"><?php _e('get items with either tags', 'grand-media'); ?></option>
158
+ <option <?php selected($tag__condition, 'tag__and'); ?> value="tag__and"><?php _e('get items that have all listed tags', 'grand-media'); ?></option>
159
+ <option <?php selected($tag__condition, 'tag__not_in'); ?> value="tag__not_in"><?php _e('exclude items that have any of the listed tags', 'grand-media'); ?></option>
160
+ </select>
161
+ </div>
162
+ </div>
163
+ </div>
164
+
165
+ <?php } ?>
166
+ <div class="form-group">
167
+ <label><?php _e('Terms Relation', 'grand-media'); ?> </label>
168
+
169
+ <div class="row">
170
+ <div class="col-xs-4">
171
+ <select name="gmedia_filter[terms_relation]" class="form-control input-sm">
172
+ <option <?php selected($filter_data['terms_relation'], ''); ?> value=""><?php _e('AND'); ?></option>
173
+ <option <?php selected($filter_data['terms_relation'], 'OR'); ?> value="OR"><?php _e('OR'); ?></option>
174
+ </select>
175
+ </div>
176
+ <div class="col-xs-8">
177
+ <p class="help-block"><?php _e('allows you to describe the relationship between the taxonomy queries', 'grand-media'); ?></p>
178
+ </div>
179
+ </div>
180
+ </div>
181
+ <div class="form-group">
182
+ <label><?php _e('Search', 'grand-media'); ?></label>
183
+
184
+ <div class="row">
185
+ <div class="col-xs-8">
186
+ <input type="text" class="form-control input-sm" placeholder="<?php _e('Search string or terms separated by comma', 'grand-media'); ?>" value="<?php echo $filter_data['s']; ?>" name="gmedia_filter[s]">
187
+ </div>
188
+ <div class="col-xs-4">
189
+ <div class="checkbox"><label><input type="checkbox" name="gmedia_filter[exact]" value="yes"<?php echo $filter_data['exact']? ' checked="checked"' : ''; ?> /> <?php _e('Search exactly string', 'grand-media'); ?></label></div>
190
+ </div>
191
+ </div>
192
+ </div>
193
+ <div class="form-group">
194
+ <div class="row">
195
+ <div class="col-xs-8">
196
+ <div class="pull-right"><a id="use_lib_selected" class="label label-primary" href="#libselected"><?php _e('Use selected in Library', 'grand-media'); ?></a></div>
197
+ <label><?php _e('Gmedia IDs <small class="text-muted">separated by comma</small>', 'grand-media'); ?> </label>
198
+ <?php $value = !empty($gmedia_id)? implode(',', wp_parse_id_list($gmedia_id)) : ''; ?>
199
+ <textarea id="gmedia__ids" name="filter_data[gmedia_id]" rows="1" class="form-control input-sm" style="resize:vertical;" placeholder="<?php echo esc_attr(__('Gmedia IDs...', 'grand-media')); ?>"><?php echo $value; ?></textarea>
200
+ </div>
201
+ <div class="col-xs-4">
202
+ <label>&nbsp;</label>
203
+ <select name="filter_data[gmedia_id__condition]" class="form-control input-sm">
204
+ <option <?php selected($gmedia_id__condition, 'gmedia__in'); ?> value="gmedia__in"><?php _e('get gmedia IDs', 'grand-media'); ?></option>
205
+ <option <?php selected($gmedia_id__condition, 'gmedia__not_in'); ?> value="gmedia__not_in"><?php _e('exclude gmedia IDs', 'grand-media'); ?></option>
206
+ </select>
207
+ </div>
208
+ </div>
209
+ <p class="help-block"><?php _e('You can select items you want to add here right in Gmedia Library and then return here and click button "Use selected in Library"', 'grand-media'); ?></p>
210
+ </div>
211
+ <div class="form-group">
212
+ <div class="row">
213
+ <div class="col-xs-4">
214
+ <label><?php _e('Mime Type', 'grand-media'); ?> </label>
215
+ <select name="gmedia_filter[mime_type][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('All types...', 'grand-media')); ?>">
216
+ <option value=""><?php _e('All types...', 'grand-media'); ?></option>
217
+ <option <?php echo in_array('image', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="image"><?php _e('Image', 'grand-media'); ?></option>
218
+ <option <?php echo in_array('audio', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="audio"><?php _e('Audio', 'grand-media'); ?></option>
219
+ <option <?php echo in_array('video', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="video"><?php _e('Video', 'grand-media'); ?></option>
220
+ <option <?php echo in_array('text', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="text"><?php _e('Text', 'grand-media'); ?></option>
221
+ <option <?php echo in_array('application', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="application"><?php _e('Application', 'grand-media'); ?></option>
222
+ </select>
223
+ </div>
224
+ <div class="col-xs-4">
225
+ <label><?php _e('Authors', 'grand-media'); ?></label>
226
+ <?php if(gm_user_can('show_others_media')) {
227
+ $user_ids = $gmCore->get_editable_user_ids();
228
+ if(!in_array($user_ID, $user_ids)) {
229
+ array_push($user_ids, $user_ID);
230
+ }
231
+ $filter_users = get_users(array('include' => $user_ids));
232
+ $users = '';
233
+ if(count($filter_users)) {
234
+ foreach((array)$filter_users as $user) {
235
+ $user->ID = (int)$user->ID;
236
+ $_selected = in_array($user->ID, $author_id)? ' selected="selected"' : '';
237
+ $users .= "<option value='$user->ID'$_selected>" . esc_html($user->display_name) . "</option>";
238
+ }
239
+ }
240
+ $setvalue = !empty($author_id)? 'data-setvalue="' . implode(',', $author_id) . '"' : '';
241
+ ?>
242
+ <select <?php echo $setvalue; ?> name="filter_data[author_id][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('All authors...', 'grand-media')); ?>">
243
+ <option value=""><?php _e('All authors...', 'grand-media'); ?></option>
244
+ <?php echo $users; ?>
245
+ </select>
246
+ <?php } else { ?>
247
+ <input type="text" readonly="readonly" name="filter_data[author_id][]" class="gmedia-combobox form-control input-sm" value="<?php the_author_meta('display_name', $user_ID); ?>"/>
248
+ <input type="hidden" name="filter_data[author_id__condition]" value="author__in"/>
249
+ <?php } ?>
250
+ </div>
251
+ <?php if(gm_user_can('show_others_media')) { ?>
252
+ <div class="col-xs-4">
253
+ <label>&nbsp;</label>
254
+ <select name="filter_data[author_id__condition]" class="form-control input-sm">
255
+ <option <?php selected($author_id__condition, 'author__in'); ?> value="author__in"><?php _e('get authors', 'grand-media'); ?></option>
256
+ <option <?php selected($author_id__condition, 'author__not_in'); ?> value="author__not_in"><?php _e('exclude authors', 'grand-media'); ?></option>
257
+ </select>
258
+ </div>
259
+ <?php } ?>
260
+ </div>
261
+ </div>
262
+ <div class="form-group">
263
+ <div class="row">
264
+ <div class="col-xs-4">
265
+ <label><?php _e('Year', 'grand-media'); ?></label>
266
+ <input type="text" class="form-control input-sm" placeholder="<?php _e('4 digit year e.g. 2011', 'grand-media'); ?>" value="<?php echo $filter_data['year']; ?>" name="gmedia_filter[year]">
267
+ </div>
268
+ <div class="col-xs-4">
269
+ <label><?php _e('Month', 'grand-media'); ?></label>
270
+ <input type="text" class="form-control input-sm" placeholder="<?php _e('from 1 to 12', 'grand-media'); ?>" value="<?php echo $filter_data['monthnum']; ?>" name="gmedia_filter[monthnum]">
271
+ </div>
272
+ <div class="col-xs-4">
273
+ <label><?php _e('Day', 'grand-media'); ?></label>
274
+ <input type="text" class="form-control input-sm" placeholder="<?php _e('from 1 to 31', 'grand-media'); ?>" value="<?php echo $filter_data['day']; ?>" name="gmedia_filter[day]">
275
+ </div>
276
+ </div>
277
+ </div>
278
+ <div class="form-group">
279
+ <?php foreach($filter_data['meta_query'] as $i => $q) {
280
+ if($i) {
281
+ continue;
282
+ }
283
+ ?>
284
+ <div class="row">
285
+ <div class="col-xs-6 col-sm-3">
286
+ <label><?php _e('Custom Field Key', 'grand-media'); ?></label>
287
+ <input type="text" class="form-control input-sm" value="<?php echo $q['key']; ?>" name="gmedia_filter[meta_query][<?php echo $i; ?>][key]">
288
+ <span class="help-block"><?php _e('Display items with this field key', 'grand-media'); ?></span>
289
+ </div>
290
+ <div class="col-xs-6 col-sm-3">
291
+ <label><?php _e('Custom Field Value', 'grand-media'); ?></label>
292
+ <input type="text" class="form-control input-sm" value="<?php echo $q['value']; ?>" name="gmedia_filter[meta_query][<?php echo $i; ?>][value]">
293
+ <span class="help-block"><?php _e('Display items with this field value', 'grand-media'); ?></span>
294
+ </div>
295
+ <div class="col-xs-6 col-sm-3">
296
+ <label><?php _e('Compare Operator', 'grand-media'); ?></label>
297
+ <select class="form-control input-sm" name="gmedia_filter[meta_query][<?php echo $i; ?>][compare]">
298
+ <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
299
+ <option <?php selected($q['compare'], '='); ?> value="=">= (<?php _e('Default', 'grand-media'); ?>)</option>
300
+ <option <?php selected($q['compare'], '!='); ?> value="!=">!=</option>
301
+ <option <?php selected($q['compare'], '>'); ?> value="&gt;">&gt;</option>
302
+ <option <?php selected($q['compare'], '>='); ?> value="&gt;=">&gt;=</option>
303
+ <option <?php selected($q['compare'], '<'); ?> value="&lt;">&lt;</option>
304
+ <option <?php selected($q['compare'], '<='); ?> value="&lt;=">&lt;=</option>
305
+ <option <?php selected($q['compare'], 'LIKE'); ?> value="LIKE">LIKE</option>
306
+ <option <?php selected($q['compare'], 'NOT LIKE'); ?> value="NOT LIKE">NOT LIKE</option>
307
+ <?php /* ?>
308
+ <option <?php selected($q['compare'], 'IN'); ?> value="IN">IN</option>
309
+ <option <?php selected($q['compare'], 'NOT IN'); ?> value="NOT IN">NOT IN</option>
310
+ <option <?php selected($q['compare'], 'BETWEEN'); ?> value="BETWEEN">BETWEEN</option>
311
+ <option <?php selected($q['compare'], 'NOT BETWEEN'); ?> value="NOT BETWEEN">NOT BETWEEN</option>
312
+ <?php */ ?>
313
+ <option <?php selected($q['compare'], 'EXISTS'); ?> value="EXISTS">EXISTS</option>
314
+ </select>
315
+ <span class="help-block"><?php _e('Operator to test the field value', 'grand-media'); ?></span>
316
+ </div>
317
+ <div class="col-xs-6 col-sm-3">
318
+ <label><?php _e('Meta Type', 'grand-media'); ?></label>
319
+ <select class="form-control input-sm" name="gmedia_filter[meta_query][<?php echo $i; ?>][type]">
320
+ <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
321
+ <option <?php selected($q['type'], 'NUMERIC'); ?> value="NUMERIC">NUMERIC</option>
322
+ <option <?php selected($q['type'], 'BINARY'); ?> value="BINARY">BINARY</option>
323
+ <option <?php selected($q['type'], 'DATE'); ?> value="DATE">DATE</option>
324
+ <option <?php selected($q['type'], 'CHAR'); ?> value="CHAR">CHAR (<?php _e('Default', 'grand-media'); ?>)</option>
325
+ <option <?php selected($q['type'], 'DATETIME'); ?> value="DATETIME">DATETIME</option>
326
+ <option <?php selected($q['type'], 'DECIMAL'); ?> value="DECIMAL">DECIMAL</option>
327
+ <option <?php selected($q['type'], 'SIGNED'); ?> value="SIGNED">SIGNED</option>
328
+ <option <?php selected($q['type'], 'TIME'); ?> value="TIME">TIME</option>
329
+ <option <?php selected($q['type'], 'UNSIGNED'); ?> value="UNSIGNED">UNSIGNED</option>
330
+ </select>
331
+ <span class="help-block"><?php _e('Custom field type', 'grand-media'); ?></span>
332
+ </div>
333
+ </div>
334
+ <?php } ?>
335
+ </div>
336
+ <div class="form-group">
337
+ <div class="row">
338
+ <div class="col-xs-6 col-sm-3">
339
+ <label><?php _e('Order', 'grand-media'); ?></label>
340
+ <select class="form-control input-sm" name="gmedia_filter[order]">
341
+ <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
342
+ <option <?php selected($filter_data['order'], 'ASC'); ?> value="ASC"><?php _e('ASC', 'grand-media'); ?></option>
343
+ <option <?php selected($filter_data['order'], 'DESC'); ?> value="DESC"><?php _e('DESC - Default', 'grand-media'); ?></option>
344
+ </select>
345
+ <span class="help-block"><?php _e('Ascending or Descending order', 'grand-media'); ?></span>
346
+ </div>
347
+ <div class="col-xs-6 col-sm-3">
348
+ <label><?php _e('Order by', 'grand-media'); ?></label>
349
+ <select class="form-control input-sm" name="gmedia_filter[orderby]">
350
+ <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
351
+ <option <?php selected($filter_data['orderby'], 'none'); ?> value="none"><?php _e('None', 'grand-media'); ?></option>
352
+ <option <?php selected($filter_data['orderby'], 'rand'); ?> value="rand"><?php _e('Random', 'grand-media'); ?></option>
353
+ <option <?php selected($filter_data['orderby'], 'id'); ?> value="id"><?php _e('ID', 'grand-media'); ?></option>
354
+ <option <?php selected($filter_data['orderby'], 'title'); ?> value="title"><?php _e('Title', 'grand-media'); ?></option>
355
+ <option <?php selected($filter_data['orderby'], 'gmuid'); ?> value="gmuid"><?php _e('Filename', 'grand-media'); ?></option>
356
+ <option <?php selected($filter_data['orderby'], 'date'); ?> value="date"><?php _e('Date - Default', 'grand-media'); ?></option>
357
+ <option <?php selected($filter_data['orderby'], 'modified'); ?> value="modified"><?php _e('Modified Date', 'grand-media'); ?></option>
358
+ <option <?php selected($filter_data['orderby'], 'author'); ?> value="author"><?php _e('Author', 'grand-media'); ?></option>
359
+ <option <?php selected($filter_data['orderby'], 'gmedia__in'); ?> value="gmedia__in"><?php _e('Selected Order', 'grand-media'); ?></option>
360
+ <option <?php selected($filter_data['orderby'], 'meta_value'); ?> value="meta_value"><?php _e('Custom Field Value', 'grand-media'); ?></option>
361
+ <option <?php selected($filter_data['orderby'], 'meta_value_num'); ?> value="meta_value_num"><?php _e('Custom Field Value (Numeric)', 'grand-media'); ?></option>
362
+ </select>
363
+ <span class="help-block"><?php _e('Sort retrieved posts by', 'grand-media'); ?></span>
364
+ </div>
365
+ <div class="col-xs-6 col-sm-3">
366
+ <label><?php _e('Limit', 'grand-media'); ?></label>
367
+ <input type="text" class="form-control input-sm" value="<?php echo $filter_data['limit']; ?>" name="gmedia_filter[limit]" placeholder="<?php _e('leave empty for no limit', 'grand-media'); ?>">
368
+ <span class="help-block"><?php _e('Limit number of gmedia items', 'grand-media'); ?></span>
369
+ </div>
370
+ <div class="col-xs-6 col-sm-3 text-right">
371
+ <label style="display:block;">&nbsp;</label>
372
+ <button type="submit" class="btn btn-primary btn-sm" name="gmedia_filter_save"><?php _e('Save', 'grand-media'); ?></button>
373
+ </div>
374
+ </div>
375
+ </div>
376
+ </form>
377
+ <script type="text/javascript">
378
+ jQuery(function($) {
379
+ <?php if(gm_user_can('terms')){ ?>
380
+ $('.gmedia-combobox').each(function() {
381
+ var select = $(this).selectize({
382
+ create: false,
383
+ hideSelected: true,
384
+ allowEmptyOption: true
385
+ });
386
+ var val = $(this).data('setvalue');
387
+ if(val) {
388
+ val = val.toString().split(',');
389
+ select[0].selectize.setValue(val);
390
+ }
391
+ });
392
+ <?php } ?>
393
+
394
+ $('#use_lib_selected').on('click', function() {
395
+ var field = $('#gmedia__ids');
396
+ var valData = field.val().split(',');
397
+ var storedData = getStorage('gmuser_<?php echo $user_ID; ?>_');
398
+ storedData = storedData.get('library').split(',');
399
+ valData = $.grep(valData, function(e) {
400
+ return e;
401
+ });
402
+ $.each(storedData, function(i, id) {
403
+ if(!id) {
404
+ return true;
405
+ }
406
+ if($.inArray(id, valData) === -1) {
407
+ valData.push(id);
408
+ }
409
+ });
410
+ field.val(valData.join(', '));
411
+ });
412
+ });
413
+
414
+ </script>
415
+
416
+ <?php if(gm_user_can('edit_others_media')) { ?>
417
+ <div class="modal fade gmedia-modal" id="gallModal" tabindex="-1" role="dialog" aria-hidden="true">
418
+ <div class="modal-dialog"></div>
419
+ </div>
420
+ <?php } ?>
admin/pages/taxonomy/tpl/filter-list-item.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Filter list item
4
+ *
5
+ * @var $item
6
+ * @var $gmedia_url
7
+ */
8
+ ?>
9
+ <div class="cb_list-item list-group-item term-list-item <?php echo implode(' ', $item->classes); ?>">
10
+ <div class="row cb_term-object">
11
+ <div class="term_id">#<?php echo $item->term_id; ?></div>
12
+ <div class="col-xs-6 term-label">
13
+ <div class="checkbox">
14
+ <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> value="<?php echo $item->term_id; ?>"/>
15
+ <?php if($item->allow_edit) { ?>
16
+ <a class="term_name" href="<?php echo add_query_arg(array('edit_item' => $item->term_id), $gmedia_url); ?>"><?php echo esc_html($item->name); ?></a>
17
+ <?php } else { ?>
18
+ <span class="term_name"><?php echo esc_html($item->name); ?></span>
19
+ <?php } ?>
20
+ <span class="term_info_author"><?php
21
+ if($item->global) {
22
+ echo $item->author_name? sprintf(__('by %s', 'grand-media'), $item->author_name) : '(' . __('deleted author', 'grand-media') . ')';
23
+ } else {
24
+ echo '(' . __('no author', 'grand-media') . ')';
25
+ }
26
+ ?></span>
27
+
28
+ <div class="object-actions">
29
+ <?php $action_links = gmedia_term_item_actions($item);
30
+ echo implode('', $action_links);
31
+ ?>
32
+ </div>
33
+ <?php if(!empty($item->description)) { ?>
34
+ <div class="term-description"><?php echo esc_html(nl2br($item->description)); ?></div>
35
+ <?php } ?>
36
+ </div>
37
+ </div>
38
+ <div class="col-xs-6">
39
+ <p class="term-meta" style="margin:10px 0;">
40
+ <?php
41
+ if(isset($item->meta['_query'][0])) {
42
+ echo '<b>' . __('Query:') . "</b> " . str_replace(',"', ', "', json_encode($item->meta['_query'][0]));
43
+ }
44
+ ?>
45
+ </p>
46
+ </div>
47
+ </div>
48
+ </div>
admin/pages/taxonomy/tpl/no-items.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * No term items
4
+ */
5
+ ?>
6
+ <div class="list-group-item">
7
+ <div class="well well-lg text-center">
8
+ <h4><?php _e('No items to show.', 'grand-media'); ?></h4>
9
+ </div>
10
+ </div>
11
+
admin/pages/taxonomy/tpl/tag-create-item.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Create tags form
4
+ */
5
+
6
+ global $gmProcessor;
7
+ $gmedia_url = $gmProcessor->url;
8
+ ?>
9
+ <form method="post" id="gmedia-edit-term" name="gmAddTerms" class="panel-body" action="<?php echo add_query_arg(array('term' => 'gmedia_tag'), $gmedia_url); ?>" style="padding-bottom:0; border-bottom:1px solid #ddd;">
10
+ <div class="row">
11
+ <div class="form-group col-xs-9">
12
+ <label><?php _e('Tags', 'grand-media'); ?>
13
+ <small class="text-muted">(<?php _e('you can type multiple tags separated by comma') ?>)</small>
14
+ </label>
15
+ <input type="text" class="form-control input-sm" name="term[name]" placeholder="<?php _e('Tag Names', 'grand-media'); ?>" required/>
16
+ </div>
17
+ <div class="col-xs-3" style="padding-top:24px;">
18
+ <?php
19
+ wp_original_referer_field(true, 'previous');
20
+ wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
21
+ ?>
22
+ <input type="hidden" name="term[taxonomy]" value="gmedia_tag"/>
23
+ <button type="submit" class="btn btn-primary btn-sm" name="gmedia_tag_add"><?php _e('Add New Tags', 'grand-media'); ?></button>
24
+ </div>
25
+ </div>
26
+ </form>
27
+
admin/pages/taxonomy/tpl/tag-list-item.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tag list item
4
+ *
5
+ * @var $item
6
+ */
7
+ ?>
8
+ <div class="cb_list-item list-group-item term-list-item <?php echo implode(' ', $item->classes); ?>">
9
+ <div class="row cb_term-object" id="tag_<?php echo $item->term_id; ?>">
10
+ <div class="term_id">#<?php echo $item->term_id; ?></div>
11
+ <div class="col-xs-6 term-label">
12
+ <div class="checkbox">
13
+ <input name="doaction[]" type="checkbox"<?php echo $item->selected? ' checked="checked"' : ''; ?> value="<?php echo $item->term_id; ?>"/>
14
+ <?php if($item->allow_edit) { ?>
15
+ <a class="edit_tag_link" href="#tag_<?php echo $item->term_id; ?>"><?php echo esc_html($item->name); ?></a>
16
+ <span class="edit_tag_form" style="display:none;"><input class="edit_tag_input" type="text" data-tag_id="<?php echo $item->term_id; ?>" name="gmedia_tag_name[<?php echo $item->term_id; ?>]" value="<?php echo esc_attr($item->name); ?>" placeholder="<?php echo esc_attr($item->name); ?>"/><a href="#tag_<?php echo $item->term_id; ?>" class="edit_tag_save btn btn-link glyphicon glyphicon-pencil"></a></span>
17
+ <?php } else { ?>
18
+ <span><?php echo esc_html($item->name); ?></span>
19
+ <?php } ?>
20
+
21
+ <div class="object-actions">
22
+ <?php $action_links = gmedia_term_item_actions($item);
23
+ echo implode('', $action_links);
24
+ ?>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ <div class="col-xs-6 term-images">
29
+ <?php gmedia_term_item_thumbnails($item); ?>
30
+ </div>
31
+ </div>
32
+ </div>
admin/pages/taxonomy/tpl/term-panel-heading.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Panel heading for term
4
+ *
5
+ * @var $term_id
6
+ * @var $gmedia_term_taxonomy
7
+ * @var $gmedia_terms_pager
8
+ * @var $gmProcessor
9
+ */
10
+ $taxterm = str_replace('gmedia_', '', $gmedia_term_taxonomy);
11
+ ?>
12
+ <div class="panel-heading clearfix">
13
+ <div class="btn-toolbar pull-left">
14
+ <div class="btn-group" style="margin-right:20px;">
15
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
16
+ <?php _e('Return to') ?> <span class="caret"></span>
17
+ </button>
18
+ <ul class="dropdown-menu" role="menu">
19
+ <li<?php echo ('gmedia_album' == $gmedia_term_taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_album'), $gmedia_url); ?>"><?php _e('Albums', 'grand-media'); ?></a></li>
20
+ <li<?php echo ('gmedia_tag' == $gmedia_term_taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_tag'), $gmedia_url); ?>"><?php _e('Tags', 'grand-media'); ?></a></li>
21
+ <li<?php echo ('gmedia_category' == $gmedia_term_taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_category'), $gmedia_url); ?>"><?php _e('Categories', 'grand-media'); ?></a></li>
22
+ <li class="divider"></li>
23
+ <li<?php echo ('gmedia_filter' == $gmedia_term_taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_filter'), $gmedia_url); ?>"><?php _e('Custom Filters', 'grand-media'); ?></a></li>
24
+ </ul>
25
+ </div>
26
+
27
+ <?php if($term_id) { ?>
28
+ <div class="btn-group">
29
+ <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
30
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
31
+ <span class="caret"></span>
32
+ <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
33
+ </button>
34
+ <ul class="dropdown-menu" role="menu">
35
+ <?php $taxkey = ('gmedia_filter' == $gmedia_term_taxonomy)? 'custom_filter' : $taxterm . '__in'; ?>
36
+ <li><a href="<?php echo add_query_arg(array('page' => 'GrandMedia', $taxkey => $term->term_id), admin_url('admin.php')); ?>"><?php _e('Show in Gmedia Library', 'grand-media'); ?></a></li>
37
+ </ul>
38
+ </div>
39
+ <?php } ?>
40
+ </div>
41
+
42
+ </div>
admin/pages/taxonomy/tpl/terms-create-alert.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Alert capability
4
+ */
5
+ ?>
6
+ <div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
7
+ <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only"><?php _e('Close', 'grand-media'); ?></span></button>
8
+ <strong><?php _e('Info:', 'grand-media'); ?></strong> <?php _e('You are not allowed to add new terms', 'grand-media'); ?>
9
+ </div>
10
+
admin/pages/taxonomy/tpl/terms-panel-heading.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Panel heading for terms
4
+ *
5
+ * @var $gmedia_term_taxonomy
6
+ * @var $gmedia_terms_pager
7
+ * @var $gmProcessor
8
+ */
9
+ ?>
10
+ <div class="panel-heading-fake"></div>
11
+ <div class="panel-heading clearfix">
12
+
13
+ <?php if('gmedia_category' != $gmedia_term_taxonomy) {
14
+
15
+ include(GMEDIA_ABSPATH . 'admin/tpl/search-form.php');
16
+
17
+ echo $gmedia_terms_pager;
18
+
19
+ } ?>
20
+
21
+ <div class="btn-toolbar pull-left">
22
+ <?php if('gmedia_category' != $gmedia_term_taxonomy) { ?>
23
+ <div class="btn-group gm-checkgroup" id="cb_global-btn">
24
+ <span class="btn btn-default active"><input class="doaction" id="cb_global"
25
+ data-group="cb_term-object" type="checkbox"/></span>
26
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
27
+ <span class="caret"></span>
28
+ <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
29
+ </button>
30
+ <ul class="dropdown-menu" role="menu">
31
+ <li><a data-select="total" href="#"><?php _e('All', 'grand-media'); ?></a></li>
32
+ <li><a data-select="none" href="#"><?php _e('None', 'grand-media'); ?></a></li>
33
+ <li class="divider"></li>
34
+ <li><a data-select="reverse" href="#" title="<?php _e('Reverse only visible items', 'grand-media'); ?>"><?php _e('Reverse', 'grand-media'); ?></a></li>
35
+ </ul>
36
+ </div>
37
+ <?php } ?>
38
+
39
+ <?php
40
+ switch($gmedia_term_taxonomy) {
41
+ case 'gmedia_filter':
42
+ $button_title = __('Show: Filters', 'grand-media');
43
+ break;
44
+ case 'gmedia_tag':
45
+ $button_title = __('Show: Tags', 'grand-media');
46
+ break;
47
+ case 'gmedia_category':
48
+ $button_title = __('Show: Categories', 'grand-media');
49
+ break;
50
+ case 'gmedia_album':
51
+ default:
52
+ $button_title = __('Show: Albums', 'grand-media');
53
+ break;
54
+ }
55
+ ?>
56
+ <div class="btn-group" style="margin-right:20px;">
57
+ <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
58
+ <?php echo $button_title ?> <span class="caret"></span>
59
+ </button>
60
+ <ul class="dropdown-menu" role="menu">
61
+ <li<?php echo ('gmedia_album' == $gmedia_term_taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_album'), $gmedia_url); ?>"><?php _e('Albums', 'grand-media'); ?></a></li>
62
+ <li<?php echo ('gmedia_tag' == $gmedia_term_taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_tag'), $gmedia_url); ?>"><?php _e('Tags', 'grand-media'); ?></a></li>
63
+ <li<?php echo ('gmedia_category' == $gmedia_term_taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_category'), $gmedia_url); ?>"><?php _e('Categories', 'grand-media'); ?></a></li>
64
+ <li class="divider"></li>
65
+ <li<?php echo ('gmedia_filter' == $gmedia_term_taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('taxonomy' => 'gmedia_filter'), $gmedia_url); ?>"><?php _e('Custom Filters', 'grand-media'); ?></a></li>
66
+ </ul>
67
+ </div>
68
+
69
+ <?php if(('gmedia_filter' == $gmedia_term_taxonomy) && gm_user_can('filter_manage')) { ?>
70
+ <a class="btn btn-success pull-left" href="<?php echo add_query_arg(array('edit_item' => '0'), $gmedia_url); ?>"><?php _e('Create Filter', 'grand-media'); ?></a>
71
+ <?php } ?>
72
+
73
+ <?php if(('gmedia_category' != $gmedia_term_taxonomy) && !empty($gmedia_terms)) { ?>
74
+ <div class="btn-group">
75
+ <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
76
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
77
+ <span class="caret"></span>
78
+ <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
79
+ </button>
80
+ <?php
81
+ $rel_selected_show = 'rel-selected-show';
82
+ $rel_selected_hide = 'rel-selected-hide';
83
+ ?>
84
+ <ul class="dropdown-menu" role="menu">
85
+ <li class="dropdown-header <?php echo $rel_selected_hide; ?>"><span><?php _e("Select items to see more actions", "grand-media"); ?></span></li>
86
+ <li class="<?php echo $rel_selected_show . (gm_user_can('terms_delete')? '' : ' disabled'); ?>">
87
+ <a href="<?php echo wp_nonce_url($gmCore->get_admin_url(array('delete' => 'selected'), array('filter')), 'gmedia_delete') ?>" class="gmedia-delete" data-confirm="<?php _e("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media"); ?>"><?php _e('Delete Selected Items', 'grand-media'); ?></a>
88
+ </li>
89
+ <?php do_action('gmedia_terms_action_list'); ?>
90
+ </ul>
91
+ </div>
92
+
93
+ <?php
94
+ $filter_selected = $gmCore->_req('filter');
95
+ $filter_selected_arg = $filter_selected? false : 'selected';
96
+ ?>
97
+ <form class="btn-group" id="gm-selected-btn" name="gm-selected-form" action="<?php echo add_query_arg(array('term' => $gmedia_term_taxonomy, 'filter' => $filter_selected_arg), $gmedia_url); ?>" method="post">
98
+ <button type="submit" class="btn btn<?php echo ('selected' == $filter_selected)? '-success' : '-info' ?>"><?php printf(__('%s selected', 'grand-media'), '<span id="gm-selected-qty">' . count($gmProcessor->selected_items) . '</span>'); ?></button>
99
+ <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
100
+ <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
101
+ <input type="hidden" id="gm-selected" data-userid="<?php echo $user_ID; ?>" data-key="<?php echo $gmedia_term_taxonomy; ?>" name="selected_items" value="<?php echo implode(',', $gmProcessor->selected_items); ?>"/>
102
+ <ul class="dropdown-menu" role="menu">
103
+ <li><a id="gm-selected-show" href="#show"><?php
104
+ if(!$filter_selected) {
105
+ _e('Show only selected items', 'grand-media');
106
+ } else {
107
+ _e('Show all gmedia items', 'grand-media');
108
+ }
109
+ ?></a></li>
110
+ <li><a id="gm-selected-clear" href="#clear"><?php _e('Clear selected items', 'grand-media'); ?></a></li>
111
+ <?php /*
112
+ <li class="<?php echo gm_user_can('gallery_manage')? '' : 'disabled'; ?>">
113
+ <a href="#libModal" data-modal="quick_gallery" data-action="gmedia_get_modal" class="gmedia-modal"><?php _e('Quick Gallery from Selected', 'grand-media'); ?></a>
114
+ </li>
115
+ <?php */ ?>
116
+ </ul>
117
+ </form>
118
+ <?php } ?>
119
+
120
+ </div>
121
+ </div>
122
+
admin/{class.processor.addmedia.php → processor/class.processor.addmedia.php} RENAMED
File without changes
admin/{class.processor.galleries.php → processor/class.processor.galleries.php} RENAMED
File without changes
admin/{class.processor.library.php → processor/class.processor.library.php} RENAMED
@@ -6,9 +6,9 @@
6
  class GmediaProcessor_Library extends GmediaProcessor {
7
 
8
  public static $cookie_key = false;
9
- public $url;
10
  public $edit_mode = false;
11
  public $selected_items = array();
 
12
  public $query_args;
13
  public $filters = array();
14
 
@@ -24,7 +24,8 @@ class GmediaProcessor_Library extends GmediaProcessor {
24
  self::$cookie_key = "gmuser_{$user_ID}_library";
25
  $this->edit_mode = $gmCore->_get('edit_mode', false, true);
26
  $this->url = add_query_arg(array('page' => $this->page, 'edit_mode' => $this->edit_mode), admin_url('admin.php'));
27
- $this->selected_items = self::selected_items(self::$cookie_key);
 
28
 
29
  }
30
 
@@ -38,7 +39,7 @@ class GmediaProcessor_Library extends GmediaProcessor {
38
  $args['status'] = $gmCore->_get('status');
39
  $args['page'] = $gmCore->_get('pager');
40
  $args['per_page'] = $gmCore->_get('per_page', $this->user_options['per_page_gmedia']);
41
- $args['author__in'] = self::filter_by_author($gmCore->_get('author'));
42
  $args['alb'] = $gmCore->_get('alb');
43
  $args['album__in'] = $gmCore->_get('album__in');
44
  $args['album__not_in'] = $gmCore->_get('album__not_in');
@@ -58,10 +59,24 @@ class GmediaProcessor_Library extends GmediaProcessor {
58
  $args['s'] = false;
59
  }
60
 
61
- if(('selected' == $gmCore->_req('filter')) && !empty($this->selected_items)) {
62
- $args['gmedia__in'] = $this->selected_items;
 
63
  $args['orderby'] = $gmCore->_get('orderby', 'gmedia__in');
64
  $args['order'] = $gmCore->_get('order', 'ASC');
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
  $query_args = apply_filters('gmedia_library_query_args', $args);
@@ -85,8 +100,8 @@ class GmediaProcessor_Library extends GmediaProcessor {
85
  }
86
  }
87
 
88
- foreach($query_args as $key => $val){
89
- if(empty($val) && ('0' !== $val) && (0 !== $val)){
90
  unset($query_args[$key]);
91
  }
92
  }
@@ -104,7 +119,7 @@ class GmediaProcessor_Library extends GmediaProcessor {
104
 
105
  $gmDB->gmedias_album_stuff($query_args);
106
  if(!empty($query_args['album__in'])) {
107
- $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $user_ID, 'include' => $query_args['album__in']));
108
  if(!empty($albums_names)) {
109
  $this->filters['filter_albums'] = array(
110
  'title' => __('Filter Album', 'grand-media'),
@@ -113,7 +128,7 @@ class GmediaProcessor_Library extends GmediaProcessor {
113
  }
114
  }
115
  if(!empty($query_args['album__not_in'])) {
116
- $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $user_ID, 'include' => $query_args['album__not_in']));
117
  if(!empty($albums_names)) {
118
  $this->filters['exclude_albums'] = array(
119
  'title' => __('Exclude Album', 'grand-media'),
@@ -178,6 +193,8 @@ class GmediaProcessor_Library extends GmediaProcessor {
178
  wp_die(__('You are not allowed to be here', 'grand-media'));
179
  }
180
 
 
 
181
  if(isset($_GET['display_mode'])) {
182
  $display_mode = $_GET['display_mode'];
183
  if(in_array($display_mode, array('grid', 'list'))) {
@@ -282,6 +299,7 @@ class GmediaProcessor_Library extends GmediaProcessor {
282
  wp_redirect($location);
283
  exit;
284
  }
 
285
  if(!empty($this->selected_items)) {
286
  if(isset($_POST['assign_category'])) {
287
  check_admin_referer('gmedia_modal');
@@ -318,6 +336,8 @@ class GmediaProcessor_Library extends GmediaProcessor {
318
  $this->error[] = sprintf(__("Category `%s` can't be assigned.", 'grand-media'), $term);
319
  }
320
  }
 
 
321
  }
322
  } else {
323
  $this->error[] = __('You are not allowed to assign terms', 'grand-media');
@@ -374,6 +394,8 @@ class GmediaProcessor_Library extends GmediaProcessor {
374
  }
375
  }
376
  }
 
 
377
  }
378
  } else {
379
  $this->error[] = __('You are not allowed to assign terms', 'grand-media');
@@ -413,7 +435,9 @@ class GmediaProcessor_Library extends GmediaProcessor {
413
  $count--;
414
  }
415
  }
416
- $this->msg[] = sprintf(__('Tags added to %d item(s)', 'grand-media'), count($term), $count);
 
 
417
  }
418
  } else {
419
  $this->error[] = __('No tags specified', 'grand-media');
@@ -443,6 +467,8 @@ class GmediaProcessor_Library extends GmediaProcessor {
443
  }
444
  }
445
  $this->msg[] = sprintf(__('%d tag(s) deleted from %d item(s)', 'grand-media'), count($term), $count);
 
 
446
  }
447
  } else {
448
  $this->error[] = __('You are not allowed to assign terms', 'grand-media');
@@ -460,15 +486,19 @@ class GmediaProcessor_Library extends GmediaProcessor {
460
  $selected_items = $this->selected_items;
461
  }
462
  if(($count = count($selected_items))) {
463
- $batch_data = array();
464
- $b_filename = $gmCore->_post('batch_filename');
465
- $b_title = $gmCore->_post('batch_title');
466
- $b_description = $gmCore->_post('batch_description');
467
- $b_link = $gmCore->_post('batch_link');
468
- $b_status = $gmCore->_post('batch_status');
 
469
  if($b_status) {
470
  $batch_data['status'] = $b_status;
471
  }
 
 
 
472
  $b_author = $gmCore->_post('batch_author');
473
  if($b_author && ('-1' != $b_author)) {
474
  $batch_data['author'] = $b_author;
@@ -581,6 +611,8 @@ class GmediaProcessor_Library extends GmediaProcessor {
581
  $i++;
582
  }
583
  $this->msg[] = sprintf(__('%d item(s) updated successfuly', 'grand-media'), $count);
 
 
584
  }
585
  } else {
586
  $this->error[] = __('You are not allowed to edit media', 'grand-media');
@@ -604,6 +636,7 @@ class GmediaProcessor_Library extends GmediaProcessor {
604
  }
605
  $this->msg[] = sprintf(__('%d item(s) updated successfuly', 'grand-media'), $count);
606
  }
 
607
  } else {
608
  $this->error[] = __('You are not allowed to edit media', 'grand-media');
609
  }
@@ -642,12 +675,18 @@ class GmediaProcessor_Library extends GmediaProcessor {
642
  }
643
  $this->selected_items = array_diff($this->selected_items, $selected_items);
644
  if(empty($this->selected_items)) {
645
- setcookie("gmuser_{$user_ID}_library", '', time() - 3600);
646
- unset($_COOKIE["gmuser_{$user_ID}_library"]);
647
- $this->selected_items = array();
648
  } else {
649
  setcookie("gmuser_{$user_ID}_library", implode(',', $this->selected_items));
650
  }
 
 
 
 
 
 
 
 
651
  }
652
  }
653
  } else {
6
  class GmediaProcessor_Library extends GmediaProcessor {
7
 
8
  public static $cookie_key = false;
 
9
  public $edit_mode = false;
10
  public $selected_items = array();
11
+ public $stack_items = array();
12
  public $query_args;
13
  public $filters = array();
14
 
24
  self::$cookie_key = "gmuser_{$user_ID}_library";
25
  $this->edit_mode = $gmCore->_get('edit_mode', false, true);
26
  $this->url = add_query_arg(array('page' => $this->page, 'edit_mode' => $this->edit_mode), admin_url('admin.php'));
27
+ $this->selected_items = parent::selected_items(self::$cookie_key);
28
+ $this->stack_items = parent::selected_items("gmuser_{$user_ID}_library_stack", 'stack_items');
29
 
30
  }
31
 
39
  $args['status'] = $gmCore->_get('status');
40
  $args['page'] = $gmCore->_get('pager');
41
  $args['per_page'] = $gmCore->_get('per_page', $this->user_options['per_page_gmedia']);
42
+ $args['author__in'] = parent::filter_by_author($gmCore->_get('author'));
43
  $args['alb'] = $gmCore->_get('alb');
44
  $args['album__in'] = $gmCore->_get('album__in');
45
  $args['album__not_in'] = $gmCore->_get('album__not_in');
59
  $args['s'] = false;
60
  }
61
 
62
+ $show_stack = false;
63
+ if(('show' == $gmCore->_req('stack')) && !empty($this->stack_items)) {
64
+ $args['gmedia__in'] = $this->stack_items;
65
  $args['orderby'] = $gmCore->_get('orderby', 'gmedia__in');
66
  $args['order'] = $gmCore->_get('order', 'ASC');
67
+ $show_stack = true;
68
+ }
69
+ if(('selected' == $gmCore->_req('filter')) && !empty($this->selected_items)) {
70
+ if($show_stack) {
71
+ $stack_items = wp_parse_id_list($this->stack_items);
72
+ $selected_items = wp_parse_id_list($this->selected_items);
73
+ $gmedia_in = array_intersect($stack_items, $selected_items);
74
+ $args['gmedia__in'] = $gmedia_in;
75
+ } else {
76
+ $args['gmedia__in'] = $this->selected_items;
77
+ $args['orderby'] = $gmCore->_get('orderby', 'gmedia__in');
78
+ $args['order'] = $gmCore->_get('order', 'ASC');
79
+ }
80
  }
81
 
82
  $query_args = apply_filters('gmedia_library_query_args', $args);
100
  }
101
  }
102
 
103
+ foreach($query_args as $key => $val) {
104
+ if(empty($val) && ('0' !== $val) && (0 !== $val)) {
105
  unset($query_args[$key]);
106
  }
107
  }
119
 
120
  $gmDB->gmedias_album_stuff($query_args);
121
  if(!empty($query_args['album__in'])) {
122
+ $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['album__in']));
123
  if(!empty($albums_names)) {
124
  $this->filters['filter_albums'] = array(
125
  'title' => __('Filter Album', 'grand-media'),
128
  }
129
  }
130
  if(!empty($query_args['album__not_in'])) {
131
+ $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['album__not_in']));
132
  if(!empty($albums_names)) {
133
  $this->filters['exclude_albums'] = array(
134
  'title' => __('Exclude Album', 'grand-media'),
193
  wp_die(__('You are not allowed to be here', 'grand-media'));
194
  }
195
 
196
+ include_once(GMEDIA_ABSPATH . 'admin/pages/library/functions.php');
197
+
198
  if(isset($_GET['display_mode'])) {
199
  $display_mode = $_GET['display_mode'];
200
  if(in_array($display_mode, array('grid', 'list'))) {
299
  wp_redirect($location);
300
  exit;
301
  }
302
+
303
  if(!empty($this->selected_items)) {
304
  if(isset($_POST['assign_category'])) {
305
  check_admin_referer('gmedia_modal');
336
  $this->error[] = sprintf(__("Category `%s` can't be assigned.", 'grand-media'), $term);
337
  }
338
  }
339
+
340
+ $this->selected_items = $this->clear_selected_items('library');
341
  }
342
  } else {
343
  $this->error[] = __('You are not allowed to assign terms', 'grand-media');
394
  }
395
  }
396
  }
397
+
398
+ $this->selected_items = $this->clear_selected_items('library');
399
  }
400
  } else {
401
  $this->error[] = __('You are not allowed to assign terms', 'grand-media');
435
  $count--;
436
  }
437
  }
438
+ $this->msg[] = sprintf(__('Tags added to %d item(s)', 'grand-media'), $count);
439
+
440
+ $this->selected_items = $this->clear_selected_items('library');
441
  }
442
  } else {
443
  $this->error[] = __('No tags specified', 'grand-media');
467
  }
468
  }
469
  $this->msg[] = sprintf(__('%d tag(s) deleted from %d item(s)', 'grand-media'), count($term), $count);
470
+
471
+ $this->selected_items = $this->clear_selected_items('library');
472
  }
473
  } else {
474
  $this->error[] = __('You are not allowed to assign terms', 'grand-media');
486
  $selected_items = $this->selected_items;
487
  }
488
  if(($count = count($selected_items))) {
489
+ $batch_data = array();
490
+ $b_filename = $gmCore->_post('batch_filename');
491
+ $b_title = $gmCore->_post('batch_title');
492
+ $b_description = $gmCore->_post('batch_description');
493
+ $b_link = $gmCore->_post('batch_link');
494
+ $b_status = $gmCore->_post('batch_status');
495
+ $b_comment_status = $gmCore->_post('batch_comment_status');
496
  if($b_status) {
497
  $batch_data['status'] = $b_status;
498
  }
499
+ if($b_comment_status) {
500
+ $batch_data['comment_status'] = $b_comment_status;
501
+ }
502
  $b_author = $gmCore->_post('batch_author');
503
  if($b_author && ('-1' != $b_author)) {
504
  $batch_data['author'] = $b_author;
611
  $i++;
612
  }
613
  $this->msg[] = sprintf(__('%d item(s) updated successfuly', 'grand-media'), $count);
614
+
615
+ $this->selected_items = $this->clear_selected_items('library');
616
  }
617
  } else {
618
  $this->error[] = __('You are not allowed to edit media', 'grand-media');
636
  }
637
  $this->msg[] = sprintf(__('%d item(s) updated successfuly', 'grand-media'), $count);
638
  }
639
+ $this->selected_items = $this->clear_selected_items('library');
640
  } else {
641
  $this->error[] = __('You are not allowed to edit media', 'grand-media');
642
  }
675
  }
676
  $this->selected_items = array_diff($this->selected_items, $selected_items);
677
  if(empty($this->selected_items)) {
678
+ $this->clear_selected_items('library');
 
 
679
  } else {
680
  setcookie("gmuser_{$user_ID}_library", implode(',', $this->selected_items));
681
  }
682
+ if(!empty($this->stack_items)) {
683
+ $this->stack_items = array_diff($this->stack_items, $selected_items);
684
+ if(empty($this->stack_items)) {
685
+ $this->clear_selected_items('library_stack');;
686
+ } else {
687
+ setcookie("gmuser_{$user_ID}_library_stack", implode(',', $this->stack_items));
688
+ }
689
+ }
690
  }
691
  }
692
  } else {
admin/{class.processor.modules.php → processor/class.processor.modules.php} RENAMED
@@ -14,6 +14,9 @@ class GmediaProcessor_Modules extends GmediaProcessor {
14
  if(!$gmCore->caps['gmedia_module_manage']) {
15
  wp_die(__('You are not allowed to manage gmedia modules', 'grand-media'));
16
  }
 
 
 
17
  if(isset($_FILES['modulezip']['tmp_name'])) {
18
  if(!empty($_FILES['modulezip']['tmp_name'])) {
19
  check_admin_referer('GmediaModule');
@@ -52,6 +55,11 @@ class GmediaProcessor_Modules extends GmediaProcessor {
52
  } elseif($wp_filesystem->errors->get_error_code()) {
53
  $result = new WP_Error('fs_error', __('Filesystem error', 'flag'), $wp_filesystem->errors);
54
  } else {
 
 
 
 
 
55
  $result = unzip_file($to_folder . $filename, $to_folder);
56
  }
57
  // Once extracted, delete the package
@@ -68,12 +76,19 @@ class GmediaProcessor_Modules extends GmediaProcessor {
68
  }
69
 
70
  if(isset($_GET['delete_module'])) {
71
- $mfold = preg_replace('/[^a-z0-9_-]+/i', '_', $_GET['delete_module']);
72
- $mpath = "{$gmCore->upload['path']}/{$gmGallery->options['folder']['module']}/{$mfold}";
73
- if($mfold && file_exists($mpath)) {
74
- check_admin_referer('gmedia_module_delete');
75
- $gmCore->delete_folder($mpath);
76
- $this->msg[] = sprintf(__("The `%s` module folder was deleted", 'flag'), $mpath);
 
 
 
 
 
 
 
77
  }
78
  }
79
 
14
  if(!$gmCore->caps['gmedia_module_manage']) {
15
  wp_die(__('You are not allowed to manage gmedia modules', 'grand-media'));
16
  }
17
+
18
+ include_once(GMEDIA_ABSPATH . 'admin/pages/modules/functions.php');
19
+
20
  if(isset($_FILES['modulezip']['tmp_name'])) {
21
  if(!empty($_FILES['modulezip']['tmp_name'])) {
22
  check_admin_referer('GmediaModule');
55
  } elseif($wp_filesystem->errors->get_error_code()) {
56
  $result = new WP_Error('fs_error', __('Filesystem error', 'flag'), $wp_filesystem->errors);
57
  } else {
58
+ $maybe_folder_dir = basename($_FILES['modulezip']['name'], '.zip');
59
+ $maybe_folder_dir = sanitize_file_name($maybe_folder_dir);
60
+ if($maybe_folder_dir && is_dir($to_folder . $maybe_folder_dir)){
61
+ $gmCore->delete_folder($to_folder . $maybe_folder_dir);
62
+ }
63
  $result = unzip_file($to_folder . $filename, $to_folder);
64
  }
65
  // Once extracted, delete the package
76
  }
77
 
78
  if(isset($_GET['delete_module'])) {
79
+ if($gmCore->_get('_wpnonce')) {
80
+ $mfold = preg_replace('/[^a-z0-9_-]+/i', '_', $_GET['delete_module']);
81
+ $mpath = "{$gmCore->upload['path']}/{$gmGallery->options['folder']['module']}/{$mfold}";
82
+ if($mfold && file_exists($mpath)) {
83
+ check_admin_referer('gmedia_module_delete');
84
+ $gmCore->delete_folder($mpath);
85
+ $location = remove_query_arg(array('_wpnonce'));
86
+ set_transient('gmedia_module_deleted', sprintf(__("The `%s` module folder was deleted", 'flag'), $mpath), 60);
87
+ wp_redirect($location);
88
+ }
89
+ } elseif(false !== ($message = get_transient('gmedia_module_deleted'))) {
90
+ delete_transient('gmedia_module_deleted');
91
+ $this->msg[] = $message;
92
  }
93
  }
94
 
admin/{class.processor.settings.php → processor/class.processor.settings.php} RENAMED
@@ -31,7 +31,13 @@ class GmediaProcessor_Settings extends GmediaProcessor {
31
  if(empty($set['endpoint'])) {
32
  $set['endpoint'] = 'gmedia';
33
  }
34
- if($set['endpoint'] !== $gmGallery->options['endpoint']) {
 
 
 
 
 
 
35
  $flush_rewrite_rules = true;
36
  }
37
 
@@ -148,12 +154,18 @@ class GmediaProcessor_Settings extends GmediaProcessor {
148
 
149
  if(isset($_POST['gmedia_settings_reset'])) {
150
  check_admin_referer('GmediaSettings');
151
- include_once(dirname(dirname(__FILE__)) . '/config/setup.php');
152
  $_temp_options = $gmGallery->options;
153
  $gmGallery->options = gmedia_default_options();
 
154
  $gmGallery->options['license_name'] = $_temp_options['license_name'];
155
  $gmGallery->options['license_key'] = $_temp_options['license_key'];
156
  $gmGallery->options['license_key2'] = $_temp_options['license_key2'];
 
 
 
 
 
157
  delete_metadata('user', 0, 'gm_screen_options', '', true);
158
  update_option('gmediaOptions', $gmGallery->options);
159
 
31
  if(empty($set['endpoint'])) {
32
  $set['endpoint'] = 'gmedia';
33
  }
34
+ if(
35
+ $set['endpoint'] !== $gmGallery->options['endpoint'] ||
36
+ $set['gmedia_post_slug'] !== $gmGallery->options['gmedia_post_slug'] ||
37
+ $set['gmedia_album_post_slug'] !== $gmGallery->options['gmedia_album_post_slug'] ||
38
+ $set['gmedia_gallery_post_slug'] !== $gmGallery->options['gmedia_gallery_post_slug'] ||
39
+ $set['gmedia_filter_post_slug'] !== $gmGallery->options['gmedia_filter_post_slug']
40
+ ) {
41
  $flush_rewrite_rules = true;
42
  }
43
 
154
 
155
  if(isset($_POST['gmedia_settings_reset'])) {
156
  check_admin_referer('GmediaSettings');
157
+ include_once(GMEDIA_ABSPATH . 'config/setup.php');
158
  $_temp_options = $gmGallery->options;
159
  $gmGallery->options = gmedia_default_options();
160
+ // don't reset license
161
  $gmGallery->options['license_name'] = $_temp_options['license_name'];
162
  $gmGallery->options['license_key'] = $_temp_options['license_key'];
163
  $gmGallery->options['license_key2'] = $_temp_options['license_key2'];
164
+ // don't reset mobile app
165
+ $gmGallery->options['site_email'] = $_temp_options['site_email'];
166
+ $gmGallery->options['site_category'] = $_temp_options['site_category'];
167
+ $gmGallery->options['site_ID'] = $_temp_options['site_ID'];
168
+ $gmGallery->options['mobile_app'] = $_temp_options['mobile_app'];
169
  delete_metadata('user', 0, 'gm_screen_options', '', true);
170
  update_option('gmediaOptions', $gmGallery->options);
171
 
admin/{class.processor.terms.php → processor/class.processor.terms.php} RENAMED
@@ -8,18 +8,66 @@ class GmediaProcessor_Terms extends GmediaProcessor {
8
  public $taxonomy;
9
  public static $cookie_key = false;
10
  public $selected_items = array();
 
11
 
12
  /**
13
  * GmediaProcessor_Library constructor.
14
  */
15
  public function __construct() {
 
 
16
  global $user_ID, $gmCore;
17
 
18
- $this->taxonomy = $gmCore->_get('term', 'gmedia_album');
 
19
  self::$cookie_key = "gmuser_{$user_ID}_{$this->taxonomy}";
20
  $this->selected_items = parent::selected_items(self::$cookie_key);
21
 
22
- parent::__construct();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
 
25
  protected function processor() {
@@ -28,7 +76,34 @@ class GmediaProcessor_Terms extends GmediaProcessor {
28
  if(!$gmCore->caps['gmedia_library']) {
29
  wp_die(__('You are not allowed to be here', 'grand-media'));
30
  }
31
- $taxonomy = $gmCore->_get('term', 'gmedia_album');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  if(($delete = $gmCore->_get('delete'))) {
34
  check_admin_referer('gmedia_delete');
@@ -68,7 +143,7 @@ class GmediaProcessor_Terms extends GmediaProcessor {
68
  } else {
69
  $this->error[] = __('You are not allowed to delete terms', 'grand-media');
70
  }
71
- } elseif(isset($_GET['edit_filter'])) {
72
  if(isset($_POST['select_author'])) {
73
  $authors = $gmCore->_post('author_ids');
74
  $location = $gmCore->get_admin_url(array('author' => (int)$authors));
@@ -77,7 +152,7 @@ class GmediaProcessor_Terms extends GmediaProcessor {
77
  }
78
  if(isset($_POST['gmedia_filter_save'])) {
79
  check_admin_referer('GmediaTerms', 'term_save_wpnonce');
80
- $edit_term = (int)$gmCore->_get('edit_filter');
81
  do {
82
  if(!$gmCore->caps['gmedia_filter_manage']) {
83
  $this->error[] = __('You are not allowed to manage filters', 'grand-media');
@@ -161,7 +236,7 @@ class GmediaProcessor_Terms extends GmediaProcessor {
161
  } else {
162
  $gmDB->add_metadata('gmedia_term', $term_id, '_query', $filter_settings);
163
 
164
- $location = add_query_arg(array('page' => $this->page, 'edit_filter' => $term_id, 'message' => 'save'), admin_url('admin.php'));
165
  set_transient('gmedia_new_filter_id', $term_id, 60);
166
  wp_redirect($location);
167
  exit;
@@ -169,7 +244,7 @@ class GmediaProcessor_Terms extends GmediaProcessor {
169
 
170
  } while(0);
171
  }
172
- if(('save' == $gmCore->_get('message')) && ($term_id = $gmCore->_get('edit_filter'))) {
173
  if(false !== get_transient('gmedia_new_filter_id')) {
174
  delete_transient('gmedia_new_filter_id');
175
  $this->msg[] = sprintf(__('Filter #%d successfuly saved', 'grand-media'), $term_id);
@@ -177,7 +252,7 @@ class GmediaProcessor_Terms extends GmediaProcessor {
177
  }
178
  } elseif(isset($_POST['gmedia_album_save'])) {
179
  check_admin_referer('GmediaTerms', 'term_save_wpnonce');
180
- $edit_term = (int)$gmCore->_get('edit_album');
181
  do {
182
  if(!$gmCore->caps['gmedia_album_manage']) {
183
  $this->error[] = __('You are not allowed to manage albums', 'grand-media');
8
  public $taxonomy;
9
  public static $cookie_key = false;
10
  public $selected_items = array();
11
+ public $query_args = array();
12
 
13
  /**
14
  * GmediaProcessor_Library constructor.
15
  */
16
  public function __construct() {
17
+ parent::__construct();
18
+
19
  global $user_ID, $gmCore;
20
 
21
+ $this->taxonomy = $gmCore->_get('taxonomy', 'gmedia_album');
22
+ $this->url = add_query_arg(array('page' => $this->page, 'taxonomy' => $this->taxonomy), admin_url('admin.php'));
23
  self::$cookie_key = "gmuser_{$user_ID}_{$this->taxonomy}";
24
  $this->selected_items = parent::selected_items(self::$cookie_key);
25
 
26
+ }
27
+
28
+ /**
29
+ * @return array
30
+ */
31
+ public function query_args() {
32
+ global $gmCore;
33
+
34
+ $args['status'] = $gmCore->_get('status');
35
+ $args['page'] = $gmCore->_get('pager', 1);
36
+ $args['number'] = $gmCore->_get('per_page', $this->user_options['per_page_gmedia_terms']);
37
+ $args['offset'] = ($args['page'] - 1) * $args['number'];
38
+ $args['global'] = parent::filter_by_author($gmCore->_get('author'));
39
+ $args['include'] = $gmCore->_get('include');
40
+ $args['search'] = $gmCore->_get('s');
41
+ $args['orderby'] = $gmCore->_get('orderby', $this->user_options['orderby_gmedia_terms']);
42
+ $args['order'] = $gmCore->_get('order', $this->user_options['sortorder_gmedia_terms']);
43
+ $args['hide_empty'] = $gmCore->_get('hide_empty');
44
+
45
+ if($args['search'] && ('#' == substr($args['search'], 0, 1))) {
46
+ $args['include'] = substr($args['search'], 1);
47
+ $args['search'] = false;
48
+ }
49
+
50
+ if(('selected' == $gmCore->_req('filter')) && !empty($this->selected_items)) {
51
+ $args['include'] = $this->selected_items;
52
+ $args['orderby'] = $gmCore->_get('orderby', 'include');
53
+ $args['order'] = $gmCore->_get('order', 'ASC');
54
+ }
55
+
56
+ $query_args = apply_filters('gmedia_terms_query_args', $args);
57
+
58
+ switch($this->taxonomy) {
59
+ case 'gmedia_filter':
60
+ $args['hide_empty'] = false;
61
+ break;
62
+ }
63
+
64
+ foreach($query_args as $key => $val){
65
+ if(empty($val) && ('0' !== $val) && (0 !== $val)){
66
+ unset($query_args[$key]);
67
+ }
68
+ }
69
+
70
+ return $query_args;
71
  }
72
 
73
  protected function processor() {
76
  if(!$gmCore->caps['gmedia_library']) {
77
  wp_die(__('You are not allowed to be here', 'grand-media'));
78
  }
79
+
80
+ include_once(GMEDIA_ABSPATH . 'admin/pages/taxonomy/functions.php');
81
+
82
+ $this->query_args = $this->query_args();
83
+
84
+ $taxonomy = $this->taxonomy;
85
+ switch($taxonomy){
86
+ case 'gmedia_album':
87
+ if(gm_user_can('album_manage')) {
88
+ add_action('gmedia_before_terms_list', 'gmedia_terms_create_album_tpl');
89
+ } else {
90
+ add_action('gmedia_before_terms_list', 'gmedia_terms_create_alert_tpl');
91
+ }
92
+ break;
93
+ case 'gmedia_tag':
94
+ if(gm_user_can('tag_manage')) {
95
+ add_action('gmedia_before_terms_list', 'gmedia_terms_create_tag_tpl');
96
+ } else {
97
+ add_action('gmedia_before_terms_list', 'gmedia_terms_create_alert_tpl');
98
+ }
99
+ break;
100
+ case 'gmedia_filter':
101
+ if(gm_user_can('filter_manage')) {
102
+ } else {
103
+ add_action('gmedia_before_terms_list', 'gmedia_terms_create_alert_tpl');
104
+ }
105
+ break;
106
+ }
107
 
108
  if(($delete = $gmCore->_get('delete'))) {
109
  check_admin_referer('gmedia_delete');
143
  } else {
144
  $this->error[] = __('You are not allowed to delete terms', 'grand-media');
145
  }
146
+ } elseif('gmedia_filter' == $this->taxonomy && isset($_GET['edit_item'])) {
147
  if(isset($_POST['select_author'])) {
148
  $authors = $gmCore->_post('author_ids');
149
  $location = $gmCore->get_admin_url(array('author' => (int)$authors));
152
  }
153
  if(isset($_POST['gmedia_filter_save'])) {
154
  check_admin_referer('GmediaTerms', 'term_save_wpnonce');
155
+ $edit_term = (int)$gmCore->_get('edit_item');
156
  do {
157
  if(!$gmCore->caps['gmedia_filter_manage']) {
158
  $this->error[] = __('You are not allowed to manage filters', 'grand-media');
236
  } else {
237
  $gmDB->add_metadata('gmedia_term', $term_id, '_query', $filter_settings);
238
 
239
+ $location = add_query_arg(array('page' => $this->page, 'taxonomy' => 'gmedia_filter', 'edit_item' => $term_id, 'message' => 'save'), admin_url('admin.php'));
240
  set_transient('gmedia_new_filter_id', $term_id, 60);
241
  wp_redirect($location);
242
  exit;
244
 
245
  } while(0);
246
  }
247
+ if(('save' == $gmCore->_get('message')) && ($term_id = $gmCore->_get('edit_item'))) {
248
  if(false !== get_transient('gmedia_new_filter_id')) {
249
  delete_transient('gmedia_new_filter_id');
250
  $this->msg[] = sprintf(__('Filter #%d successfuly saved', 'grand-media'), $term_id);
252
  }
253
  } elseif(isset($_POST['gmedia_album_save'])) {
254
  check_admin_referer('GmediaTerms', 'term_save_wpnonce');
255
+ $edit_term = (int)$gmCore->_get('edit_item');
256
  do {
257
  if(!$gmCore->caps['gmedia_album_manage']) {
258
  $this->error[] = __('You are not allowed to manage albums', 'grand-media');
admin/{class.processor.wpmedia.php → processor/class.processor.wpmedia.php} RENAMED
@@ -12,12 +12,13 @@ class GmediaProcessor_WordpressLibrary extends GmediaProcessor {
12
  * GmediaProcessor_Library constructor.
13
  */
14
  public function __construct() {
 
 
15
  global $user_ID;
16
 
17
  self::$cookie_key = "gmuser_{$user_ID}_wpmedia";
18
  $this->selected_items = parent::selected_items(self::$cookie_key);
19
 
20
- parent::__construct();
21
  }
22
 
23
  protected function processor() {
12
  * GmediaProcessor_Library constructor.
13
  */
14
  public function __construct() {
15
+ parent::__construct();
16
+
17
  global $user_ID;
18
 
19
  self::$cookie_key = "gmuser_{$user_ID}_wpmedia";
20
  $this->selected_items = parent::selected_items(self::$cookie_key);
21
 
 
22
  }
23
 
24
  protected function processor() {
admin/settings.php DELETED
@@ -1,435 +0,0 @@
1
- <?php
2
- if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
3
- die('You are not allowed to call this page directly.');
4
- }
5
-
6
- /**
7
- * gmSettings()
8
- *
9
- * @return mixed content
10
- */
11
- function gmSettings()
12
- {
13
- global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
14
-
15
- $url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
16
- $lk = isset($gmGallery->options['license_key']) ? $gmGallery->options['license_key'] : '';
17
- ?>
18
-
19
- <form id="gmediaSettingsForm" class="panel panel-default" method="post" action="<?php echo $url; ?>">
20
- <div class="panel-heading clearfix">
21
- <div class="btn-toolbar pull-left">
22
- <div class="btn-group">
23
- <button type="submit" name="gmedia_settings_reset" class="btn btn-default" data-confirm="<?php _e('Reset all Gmedia settings?', 'grand-media') ?>"><?php _e('Reset Settings', 'grand-media'); ?></button>
24
- <button type="submit" name="gmedia_settings_save" class="btn btn-primary"><?php _e('Update', 'grand-media'); ?></button>
25
- </div>
26
- </div>
27
- <?php
28
- wp_nonce_field('GmediaSettings');
29
- ?>
30
- </div>
31
- <div class="panel-body" id="gmedia-msg-panel"></div>
32
- <div class="container-fluid">
33
- <div class="tabable tabs-left">
34
- <ul id="settingsTabs" class="nav nav-tabs" style="padding:10px 0;">
35
- <li class="active"><a href="#gmedia_premium" data-toggle="tab"><?php _e('Premium Settings', 'grand-media'); ?></a></li>
36
- <li><a href="#gmedia_settings_other" data-toggle="tab"><?php _e('Other Settings', 'grand-media'); ?></a></li>
37
- <?php if (current_user_can('manage_options')) { ?>
38
- <li><a href="#gmedia_settings_cloud" data-toggle="tab"><?php _e('GmediaCloud Page', 'grand-media'); ?></a></li>
39
- <li><a href="#gmedia_settings_roles" data-toggle="tab"><?php _e('Roles/Capabilities Manager', 'grand-media'); ?></a></li>
40
- <?php } ?>
41
- <li><a href="#gmedia_settings_sysinfo" data-toggle="tab"><?php _e('System Info', 'grand-media'); ?></a></li>
42
- </ul>
43
- <div class="tab-content" style="padding-top:21px;">
44
- <fieldset id="gmedia_premium" class="tab-pane active">
45
- <p><?php _e('Enter License Key to remove backlink label from premium gallery modules.') ?></p>
46
-
47
- <div class="row">
48
- <div class="form-group col-xs-5">
49
- <label><?php _e('License Key', 'grand-media') ?>: <?php if (isset($gmGallery->options['license_name'])) {
50
- echo '<em>' . $gmGallery->options['license_name'] . '</em>';
51
- } ?></label>
52
- <input type="text" name="set[license_key]" id="license_key" class="form-control input-sm" value="<?php echo $lk; ?>"/>
53
-
54
- <div class="manual_license_activate"<?php echo(('manual' == $gmCore->_get('license_activate')) ? '' : ' style="display:none;"'); ?>>
55
- <label style="margin-top:7px;"><?php _e('License Name', 'grand-media') ?>:</label>
56
- <input type="text" name="set[license_name]" id="license_name" class="form-control input-sm" value="<?php echo $gmGallery->options['license_name']; ?>"/>
57
- <label style="margin-top:7px;"><?php _e('Additional Key', 'grand-media') ?>:</label>
58
- <input type="text" name="set[license_key2]" id="license_key2" class="form-control input-sm" value="<?php echo $gmGallery->options['license_key2']; ?>"/>
59
- </div>
60
- </div>
61
- <?php if (! ('manual' == $gmCore->_get('license_activate') || ! empty($lk))) { ?>
62
- <div class="form-group col-xs-7">
63
- <label>&nbsp;</label>
64
- <button style="display:block;" class="btn btn-success btn-sm" type="submit" name="license-key-activate"><?php _e('Activate Key', 'grand-media'); ?></button>
65
- </div>
66
- <?php } ?>
67
- </div>
68
- </fieldset>
69
-
70
- <fieldset id="gmedia_settings_other" class="tab-pane">
71
- <div class="form-group">
72
- <label><?php _e('When delete (uninstall) plugin', 'grand-media') ?>:</label>
73
- <select name="set[uninstall_dropdata]" class="form-control input-sm">
74
- <option value="all" <?php selected($gmGallery->options['uninstall_dropdata'], 'all'); ?>><?php _e('Delete database and all uploaded files', 'grand-media'); ?></option>
75
- <option value="db" <?php selected($gmGallery->options['uninstall_dropdata'], 'db'); ?>><?php _e('Delete database only and leave uploaded files', 'grand-media'); ?></option>
76
- <option value="none" <?php selected($gmGallery->options['uninstall_dropdata'], 'none'); ?>><?php _e('Do not delete database and uploaded files', 'grand-media'); ?></option>
77
- </select>
78
- </div>
79
- <div class="form-group row">
80
- <div class="col-xs-6">
81
- <label><?php _e('In Tags order gmedia', 'grand-media'); ?></label>
82
- <select name="set[in_tag_orderby]" class="form-control input-sm">
83
- <option value="ID" <?php selected($gmGallery->options['in_tag_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
84
- <option value="title" <?php selected($gmGallery->options['in_tag_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
85
- <option value="gmuid" <?php selected($gmGallery->options['in_tag_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
86
- <option value="date" <?php selected($gmGallery->options['in_tag_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
87
- <option value="modified" <?php selected($gmGallery->options['in_tag_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
88
- <option value="rand" <?php selected($gmGallery->options['in_tag_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
89
- </select>
90
- </div>
91
- <div class="col-xs-6">
92
- <label><?php _e('Sort order', 'grand-media'); ?></label>
93
- <select name="set[in_tag_order]" class="form-control input-sm">
94
- <option value="DESC" <?php selected($gmGallery->options['in_tag_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
95
- <option value="ASC" <?php selected($gmGallery->options['in_tag_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
96
- </select>
97
- </div>
98
- </div>
99
- <div class="form-group row">
100
- <div class="col-xs-6">
101
- <label><?php _e('In Category order gmedia', 'grand-media'); ?></label>
102
- <select name="set[in_category_orderby]" class="form-control input-sm">
103
- <option value="ID" <?php selected($gmGallery->options['in_category_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
104
- <option value="title" <?php selected($gmGallery->options['in_category_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
105
- <option value="gmuid" <?php selected($gmGallery->options['in_category_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
106
- <option value="date" <?php selected($gmGallery->options['in_category_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
107
- <option value="modified" <?php selected($gmGallery->options['in_category_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
108
- <option value="rand" <?php selected($gmGallery->options['in_category_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
109
- </select>
110
- </div>
111
- <div class="col-xs-6">
112
- <label><?php _e('Sort order', 'grand-media'); ?></label>
113
- <select name="set[in_category_order]" class="form-control input-sm">
114
- <option value="DESC" <?php selected($gmGallery->options['in_category_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
115
- <option value="ASC" <?php selected($gmGallery->options['in_category_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
116
- </select>
117
- </div>
118
- </div>
119
- <div class="form-group">
120
- <label><?php _e('Forbid other plugins to load their JS and CSS on Gmedia admin pages', 'grand-media') ?>:</label>
121
-
122
- <div class="checkbox" style="margin:0;">
123
- <input type="hidden" name="set[isolation_mode]" value="0"/>
124
- <label><input type="checkbox" name="set[isolation_mode]" value="1" <?php checked($gmGallery->options['isolation_mode'], '1'); ?> /> <?php _e('Enable Gmedia admin panel Isolation Mode', 'grand-media'); ?> </label>
125
-
126
- <p class="help-block"><?php _e('This option could help to avoid JS and CSS conflicts with other plugins in admin panel.', 'grand-media'); ?></p>
127
- </div>
128
- </div>
129
- <div class="form-group">
130
- <label><?php _e('Forbid theme to format Gmedia shortcode\'s content', 'grand-media') ?>:</label>
131
-
132
- <div class="checkbox" style="margin:0;">
133
- <input type="hidden" name="set[shortcode_raw]" value="0"/>
134
- <label><input type="checkbox" name="set[shortcode_raw]" value="1" <?php checked($gmGallery->options['shortcode_raw'], '1'); ?> /> <?php _e('Raw output for Gmedia Shortcode', 'grand-media'); ?> </label>
135
-
136
- <p class="help-block"><?php _e('Some themes reformat shortcodes and break it functionality (mostly when you add description to images). Turning this on should solve this problem.', 'grand-media'); ?></p>
137
- </div>
138
- </div>
139
- <div class="form-group">
140
- <label><?php _e('Debug Mode', 'grand-media') ?>:</label>
141
-
142
- <div class="checkbox" style="margin:0;">
143
- <input type="hidden" name="set[debug_mode]" value=""/>
144
- <label><input type="checkbox" name="set[debug_mode]" value="1" <?php checked($gmGallery->options['debug_mode'], '1'); ?> /> <?php _e('Enable Debug Mode on Gmedia admin pages', 'grand-media'); ?> </label>
145
- </div>
146
- </div>
147
- <?php
148
- $allowed_post_types = (array)$gmGallery->options['gmedia_post_types_support'];
149
- $args = array(
150
- 'public' => true,
151
- '_builtin' => false
152
- );
153
- $output = 'objects'; // names or objects, note names is the default
154
- $operator = 'and'; // 'and' or 'or'
155
- $post_types = get_post_types($args, $output, $operator);
156
- if (! empty($post_types)) { ?>
157
- <div class="form-group">
158
- <label style="margin-bottom:-5px;"><?php _e('Enable Gmedia Library button on custom post types', 'grand-media') ?>:</label>
159
- <input type="hidden" name="set[gmedia_post_types_support]" value=""/>
160
- <?php
161
- foreach ($post_types as $post_type) { ?>
162
- <div class="checkbox"><label><input type="checkbox" name="set[gmedia_post_types_support][]" value="<?php echo $post_type->name; ?>" <?php echo in_array($post_type->name, $allowed_post_types)? 'checked="checked"' : ''; ?> /> <?php echo $post_type->label . ' (' . $post_type->name . ')'; ?></label> </div>
163
- <?php } ?>
164
- </div>
165
- <?php } ?>
166
- </fieldset>
167
-
168
- <?php if (current_user_can('manage_options')) { ?>
169
- <fieldset id="gmedia_settings_cloud" class="tab-pane">
170
- <p><?php _e('GmediaCloud is full window template to show your galleries, albums and other gmedia content', 'grand-media'); ?></p>
171
-
172
- <p><?php _e('Each module can have it\'s own design for GmediaCloud. Here you can set default module wich will be used for sharing Albums, Tags, Categories and single Gmedia Items.', 'grand-media'); ?></p>
173
- <br/>
174
-
175
- <div class="form-group">
176
- <label><?php _e('HashID salt for unique template URL', 'grand-media') ?>:</label>
177
- <input type="text" name="GmediaHashID_salt" value="<?php echo get_option('GmediaHashID_salt'); ?>" class="form-control input-sm"/>
178
-
179
- <p class="help-block"><?php _e('Changing this string you\'ll change Gmedia template URLs.', 'grand-media'); ?></p>
180
- </div>
181
- <div class="form-group">
182
- <label><?php _e('Permalink Endpoint (GmediaCloud base)', 'grand-media') ?>:</label>
183
- <input type="text" name="set[endpoint]" value="<?php echo $gmGallery->options['endpoint']; ?>" class="form-control input-sm"/>
184
-
185
- <p class="help-block"><?php _e('Changing endpoint you\'ll change Gmedia template URLs.', 'grand-media'); ?></p>
186
- </div>
187
- <?php
188
- $modules = array();
189
- if (($plugin_modules = glob(GMEDIA_ABSPATH . 'module/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
190
- foreach ($plugin_modules as $path) {
191
- if (! file_exists($path . '/index.php')) {
192
- continue;
193
- }
194
- $module_info = array();
195
- /** @noinspection PhpIncludeInspection */
196
- include($path . '/index.php');
197
- if (empty($module_info)) {
198
- continue;
199
- }
200
- $mfold = basename($path);
201
- $modules[$mfold] = array(
202
- 'module_name' => $mfold,
203
- 'module_title' => $module_info['title'] . ' v' . $module_info['version'],
204
- 'module_url' => $gmCore->gmedia_url . "/module/{$mfold}",
205
- 'module_path' => $path
206
- );
207
- }
208
- }
209
- if (($upload_modules = glob($gmCore->upload['path'] . '/' . $gmGallery->options['folder']['module'] . '/*', GLOB_ONLYDIR | GLOB_NOSORT))) {
210
- foreach ($upload_modules as $path) {
211
- if (! file_exists($path . '/index.php')) {
212
- continue;
213
- }
214
- $module_info = array();
215
- /** @noinspection PhpIncludeInspection */
216
- include($path . '/index.php');
217
- if (empty($module_info)) {
218
- continue;
219
- }
220
- $mfold = basename($path);
221
- $modules[$mfold] = array(
222
- 'module_name' => $mfold,
223
- 'module_title' => $module_info['title'] . ' v' . $module_info['version'],
224
- 'module_url' => $gmCore->upload['url'] . "/{$gmGallery->options['folder']['module']}/{$mfold}",
225
- 'module_path' => $path
226
- );
227
- }
228
- }
229
- ?>
230
- <div class="form-group">
231
- <label><?php _e('Choose module/preset for GmediaCloud Page', 'grand-media') ?>:</label>
232
- <select class="form-control input-sm" name="set[gmediacloud_module]">
233
- <option value=""><?php _e('Choose module/preset', 'grand-media'); ?></option>
234
- <?php foreach ($modules as $mfold => $module) {
235
- echo '<optgroup label="' . esc_attr($module['module_title']) . '">';
236
- $presets = $gmDB->get_terms('gmedia_module', array('global' => $user_ID, 'status' => $mfold));
237
- $selected = selected($gmGallery->options['gmediacloud_module'], esc_attr($mfold), false);
238
- $option = array();
239
- $option['default'] = '<option ' . $selected . ' value="' . esc_attr($mfold) . '">' . '[' . $mfold . '] ' . __('Default Settings') . '</option>';
240
- foreach ($presets as $preset) {
241
- $selected = selected($gmGallery->options['gmediacloud_module'], $preset->term_id, false);
242
- if ('[' . $mfold . ']' == $preset->name) {
243
- $option['default'] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . '[' . $mfold . '] ' . __('Default Settings') . '</option>';
244
- } else {
245
- $option[] = '<option ' . $selected . ' value="' . $preset->term_id . '">' . $preset->name . '</option>';
246
- }
247
- }
248
- echo implode('', $option);
249
- echo '</optgroup>';
250
- } ?>
251
- </select>
252
-
253
- <p class="help-block"><?php _e('by default will be used Phantom module', 'grand-media'); ?></p>
254
- </div>
255
- <div class="form-group">
256
- <label><?php _e('Top Bar Social Buttons', 'grand-media'); ?></label>
257
- <select name="set[gmediacloud_socialbuttons]" class="form-control input-sm">
258
- <option value="1" <?php selected($gmGallery->options['gmediacloud_socialbuttons'], '1'); ?>><?php _e('Show Social Buttons', 'grand-media'); ?></option>
259
- <option value="0" <?php selected($gmGallery->options['gmediacloud_socialbuttons'], '0'); ?>><?php _e('Hide Social Buttons', 'grand-media'); ?></option>
260
- </select>
261
- </div>
262
- <div class="form-group">
263
- <label><?php _e('Additional JS code for GmediaCloud Page', 'grand-media') ?>:</label>
264
- <textarea name="set[gmediacloud_footer_js]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_html(stripslashes($gmGallery->options['gmediacloud_footer_js'])); ?></textarea>
265
- </div>
266
- <div class="form-group">
267
- <label><?php _e('Additional CSS code for GmediaCloud Page', 'grand-media') ?>:</label>
268
- <textarea name="set[gmediacloud_footer_css]" rows="4" cols="20" class="form-control input-sm"><?php echo esc_html(stripslashes($gmGallery->options['gmediacloud_footer_css'])); ?></textarea>
269
- </div>
270
- </fieldset>
271
-
272
- <fieldset id="gmedia_settings_roles" class="tab-pane">
273
- <p><?php _e('Select the lowest role which should be able to access the follow capabilities. Gmedia Gallery supports the standard roles from WordPress.', 'grand-media'); ?></p>
274
-
275
- <div class="form-group">
276
- <label><?php _e('Gmedia Library', 'grand-media') ?>:</label>
277
- <select name="capability[gmedia_library]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_library')); ?></select>
278
-
279
- <p class="help-block"><?php _e('Who can view Gmedia Gallery admin pages', 'grand-media'); ?></p>
280
- </div>
281
- <hr/>
282
-
283
- <div class="form-group">
284
- <label><?php _e('Upload Media Files', 'grand-media') ?>:</label>
285
- <select name="capability[gmedia_upload]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_upload')); ?></select>
286
-
287
- <p class="help-block"><?php _e('Who can upload files to Gmedia Library', 'grand-media'); ?></p>
288
- </div>
289
- <div class="col-xs-offset-1">
290
- <div class="form-group">
291
- <label><?php _e('Import Media Files', 'grand-media') ?>:</label>
292
- <select name="capability[gmedia_import]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_import')); ?></select>
293
-
294
- <p class="help-block"><?php _e('Who can import files to Gmedia Library', 'grand-media'); ?></p>
295
- </div>
296
- </div>
297
-
298
- <div class="form-group">
299
- <label><?php _e('Show Others Media in Library', 'grand-media') ?>:</label>
300
- <select name="capability[gmedia_show_others_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_show_others_media')); ?></select>
301
-
302
- <p class="help-block"><?php _e('Who can see files uploaded by other users', 'grand-media'); ?></p>
303
- </div>
304
- <div class="form-group">
305
- <label><?php _e('Edit Media', 'grand-media') ?>:</label>
306
- <select name="capability[gmedia_edit_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_edit_media')); ?></select>
307
-
308
- <p class="help-block"><?php _e('Who can edit media title, description and other properties of uploaded files', 'grand-media'); ?></p>
309
- </div>
310
- <div class="col-xs-offset-1">
311
- <div class="form-group">
312
- <label><?php _e('Edit Others Media', 'grand-media') ?>:</label>
313
- <select name="capability[gmedia_edit_others_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_edit_others_media')); ?></select>
314
-
315
- <p class="help-block"><?php _e('Who can edit files, albums/tags and galleries of other users', 'grand-media'); ?></p>
316
- </div>
317
- </div>
318
- <div class="form-group">
319
- <label><?php _e('Delete Media', 'grand-media') ?>:</label>
320
- <select name="capability[gmedia_delete_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_delete_media')); ?></select>
321
-
322
- <p class="help-block"><?php _e('Who can delete uploaded files from Gmedia Library', 'grand-media'); ?></p>
323
- </div>
324
- <div class="col-xs-offset-1">
325
- <div class="form-group">
326
- <label><?php _e('Delete Others Media', 'grand-media') ?>:</label>
327
- <select name="capability[gmedia_delete_others_media]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_delete_others_media')); ?></select>
328
-
329
- <p class="help-block"><?php _e('Who can delete files, albums/tags and galleries of other users', 'grand-media'); ?></p>
330
- </div>
331
- </div>
332
-
333
- <div class="form-group">
334
- <label><?php _e('Albums, Tags...', 'grand-media') ?>:</label>
335
- <select name="capability[gmedia_terms]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_terms')); ?></select>
336
-
337
- <p class="help-block"><?php _e('Who can assign available terms to media files', 'grand-media'); ?></p>
338
- </div>
339
- <div class="col-xs-offset-1">
340
- <div class="form-group">
341
- <label><?php _e('Manage Albums', 'grand-media') ?>:</label>
342
- <select name="capability[gmedia_album_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_album_manage')); ?></select>
343
-
344
- <p class="help-block"><?php _e('Who can create and edit own albums. It is required "Edit Others Media" capability to edit others and shared albums', 'grand-media'); ?></p>
345
- </div>
346
- <div class="form-group">
347
- <label><?php _e('Manage Filters', 'grand-media') ?>:</label>
348
- <select name="capability[gmedia_filter_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_filter_manage')); ?></select>
349
-
350
- <p class="help-block"><?php _e('Who can create and edit own custom filters. It is required "Edit Others Media" capability to edit filters you do not own', 'grand-media'); ?></p>
351
- </div>
352
- <div class="form-group">
353
- <label><?php _e('Manage Tags', 'grand-media') ?>:</label>
354
- <select name="capability[gmedia_tag_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_tag_manage')); ?></select>
355
-
356
- <p class="help-block"><?php _e('Who can create new tags. It is required "Edit Others Media" capability to edit tags', 'grand-media'); ?></p>
357
- </div>
358
- <div class="form-group">
359
- <label><?php _e('Delete Terms', 'grand-media') ?>:</label>
360
- <select name="capability[gmedia_terms_delete]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_terms_delete')); ?></select>
361
-
362
- <p class="help-block"><?php _e('Who can delete own albums. It is required "Delete Others Media" capability to delete others terms', 'grand-media'); ?></p>
363
- </div>
364
- </div>
365
-
366
- <div class="form-group">
367
- <label><?php _e('Galleries', 'grand-media') ?>:</label>
368
- <select name="capability[gmedia_gallery_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_gallery_manage')); ?></select>
369
-
370
- <p class="help-block"><?php _e('Who can create, edit and delete own galleries', 'grand-media'); ?></p>
371
- </div>
372
-
373
- <div class="form-group">
374
- <label><?php _e('Modules', 'grand-media') ?>:</label>
375
- <select name="capability[gmedia_module_manage]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_module_manage')); ?></select>
376
-
377
- <p class="help-block"><?php _e('Who can manage modules', 'grand-media'); ?></p>
378
- </div>
379
-
380
- <div class="form-group">
381
- <label><?php _e('Settings', 'grand-media') ?>:</label>
382
- <select name="capability[gmedia_settings]" class="form-control input-sm"><?php wp_dropdown_roles($gmDB->get_role('gmedia_settings')); ?></select>
383
-
384
- <p class="help-block"><?php _e('Who can change settings. Note: Capabilites can be changed only by administrator', 'grand-media'); ?></p>
385
- </div>
386
-
387
- </fieldset>
388
- <?php } ?>
389
-
390
- <fieldset id="gmedia_settings_sysinfo" class="tab-pane">
391
- <?php
392
- if ((function_exists('memory_get_usage')) && (ini_get('memory_limit'))) {
393
- $memory_limit = ini_get('memory_limit');
394
- $memory_usage = round(memory_get_usage() / (1024 * 1024), 1);
395
- echo '<p>' . __('PHP Memory Limit: ', 'grand-media') . $memory_limit . '</p>';
396
- echo '<p>' . __('PHP Memory Used: ', 'grand-media') . $memory_usage . 'M</p>';
397
- }
398
- ?>
399
- <p><?php _e('Under constraction...') ?></p>
400
-
401
- <?php
402
- if ($gmCore->_get('showdb')) {
403
- global $wpdb;
404
- $gmedia = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia");
405
- $terms = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia_term");
406
- $relation = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia_term_relationships");
407
- $images['grand-media'] = glob($gmCore->upload['path'] . '/*', GLOB_NOSORT);
408
- $images['images'] = glob($gmCore->upload['path'] . '/image/*', GLOB_NOSORT);
409
- $images['thumbs'] = glob($gmCore->upload['path'] . '/thumb/*', GLOB_NOSORT);
410
- echo '<pre style="max-height:400px; overflow:auto;">' . print_r($gmedia, true) . '</pre>';
411
- echo '<pre style="max-height:400px; overflow:auto;">' . print_r($images, true) . '</pre>';
412
- echo '<pre style="max-height:400px; overflow:auto;">' . print_r($terms, true) . '</pre>';
413
- echo '<pre style="max-height:400px; overflow:auto;">' . print_r($relation, true) . '</pre>';
414
- }
415
- ?>
416
- </fieldset>
417
- </div>
418
- <div class="clear"></div>
419
- </div>
420
- <script type="text/javascript">
421
- jQuery(function ($) {
422
- var hash = window.location.hash;
423
- if (hash) {
424
- hash = hash.replace('_tab', '');
425
- $('#settingsTabs a[href="' + hash + '"]').tab('show');
426
- }
427
- $('#gmediaSettingsForm').on('submit', function () {
428
- $(this).attr('action', $(this).attr('action') + $('#settingsTabs li.active a').attr('href') + '_tab');
429
- });
430
- });
431
- </script>
432
- </div>
433
- </form>
434
- <?php
435
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/terms.php DELETED
@@ -1,1844 +0,0 @@
1
- <?php
2
- if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
3
- die('You are not allowed to call this page directly.');
4
- }
5
-
6
- /**
7
- * gmediaTerms()
8
- *
9
- * @return mixed content
10
- */
11
- function gmediaTerms()
12
- {
13
- global $user_ID, $gmDB, $gmCore, $gmGallery, $gmProcessor;
14
-
15
- $url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
16
-
17
- $gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
18
- if (! is_array($gm_screen_options)) {
19
- $gm_screen_options = array();
20
- }
21
- $gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
22
- $orderby = ! empty($gm_screen_options['orderby_gmedia_terms']) ? $gm_screen_options['orderby_gmedia_terms'] : 'name';
23
- $order = ! empty($gm_screen_options['sortorder_gmedia_terms']) ? $gm_screen_options['sortorder_gmedia_terms'] : 'ASC';
24
- $per_page = ! empty($gm_screen_options['per_page_gmedia_terms']) ? $gm_screen_options['per_page_gmedia_terms'] : 30;
25
-
26
- $taxonomy = $gmCore->_get('term', 'gmedia_album');
27
-
28
- if ($gmCore->caps['gmedia_show_others_media']) {
29
- $author = 0;
30
- } else {
31
- $author = $user_ID;
32
- }
33
-
34
- $filter = ('selected' == $gmCore->_req('filter')) ? $gmProcessor->selected_items : null;
35
- $search_string = $gmCore->_get('s', '');
36
- if ('#' == substr($search_string, 0, 1)) {
37
- $filter = substr($search_string, 1);
38
- $search_string = '';
39
- }
40
- $args = array(
41
- 'orderby' => $gmCore->_get('orderby', $orderby),
42
- 'order' => $gmCore->_get('order', $order),
43
- 'search' => $search_string,
44
- 'number' => $gmCore->_get('number', $per_page),
45
- 'hide_empty' => $gmCore->_get('hide_empty', 0),
46
- 'page' => $gmCore->_get('pager', 1),
47
- 'include' => $filter
48
- );
49
- $args['offset'] = ($args['page'] - 1) * $args['number'];
50
-
51
- $allow_edit = 0;
52
- switch ($taxonomy) {
53
- case 'gmedia_filter':
54
- $args['hide_empty'] = 0;
55
- $allow_edit = $gmCore->caps['gmedia_filter_manage'];
56
- $args['global'] = $gmCore->_get('author', $gmCore->caps['gmedia_edit_others_media'] ? '' : array(0, $user_ID));
57
- if (! $gmCore->caps['gmedia_show_others_media']) {
58
- $args['global'] = wp_parse_id_list($args['global']);
59
- $args['global'] = array_intersect(array(0, $user_ID), $args['global']);
60
- if (empty($args['global'])) {
61
- $args['global'] = array(0, $user_ID);
62
- }
63
- }
64
- break;
65
- case 'gmedia_album':
66
- $allow_edit = $gmCore->caps['gmedia_album_manage'];
67
- $args['global'] = $gmCore->_get('author', $gmCore->caps['gmedia_edit_others_media'] ? '' : array(0, $user_ID));
68
- if (! $gmCore->caps['gmedia_show_others_media']) {
69
- $args['global'] = wp_parse_id_list($args['global']);
70
- $args['global'] = array_intersect(array(0, $user_ID), $args['global']);
71
- if (empty($args['global'])) {
72
- $args['global'] = array(0, $user_ID);
73
- }
74
- }
75
- break;
76
- case 'gmedia_tag':
77
- $allow_edit = $gmCore->caps['gmedia_tag_manage'];
78
- if ('global' == $args['orderby']) {
79
- $args['orderby'] = 'id';
80
- }
81
- break;
82
- case 'gmedia_category':
83
- $args = array();
84
- break;
85
- }
86
- $gmediaTerms = $gmDB->get_terms($taxonomy, $args);
87
-
88
- ?>
89
- <div class="panel panel-default panel-fixed-header" id="gmedia-panel">
90
- <div class="panel-heading-fake"></div>
91
- <div class="panel-heading clearfix">
92
-
93
- <?php if ('gmedia_category' != $taxonomy) { ?>
94
- <form class="form-inline gmedia-search-form" role="search" method="get">
95
- <div class="form-group">
96
- <input type="hidden" name="page" value="<?php echo $gmProcessor->page; ?>"/>
97
- <input type="hidden" name="term" value="<?php echo $taxonomy; ?>"/>
98
- <input id="gmedia-search" class="form-control input-sm" type="text" name="s" placeholder="<?php _e('Search...', 'grand-media'); ?>" value="<?php echo $gmCore->_get('s', ''); ?>"/>
99
- </div>
100
- <button type="submit" class="btn btn-default input-sm"><span class="glyphicon glyphicon-search"></span></button>
101
- </form>
102
- <?php echo $gmDB->query_pager(); ?>
103
- <?php } ?>
104
-
105
- <div class="btn-toolbar pull-left">
106
- <?php if ('gmedia_category' != $taxonomy) { ?>
107
- <div class="btn-group gm-checkgroup" id="cb_global-btn">
108
- <span class="btn btn-default active"><input class="doaction" id="cb_global"
109
- data-group="cb_term-object" type="checkbox"/></span>
110
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
111
- <span class="caret"></span>
112
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
113
- </button>
114
- <ul class="dropdown-menu" role="menu">
115
- <li><a data-select="total" href="#"><?php _e('All', 'grand-media'); ?></a></li>
116
- <li><a data-select="none" href="#"><?php _e('None', 'grand-media'); ?></a></li>
117
- <li class="divider"></li>
118
- <li><a data-select="reverse" href="#" title="<?php _e('Reverse only visible items', 'grand-media'); ?>"><?php _e('Reverse', 'grand-media'); ?></a></li>
119
- </ul>
120
- </div>
121
- <?php } ?>
122
-
123
- <?php
124
- switch ($taxonomy) {
125
- case 'gmedia_album':
126
- $button_title = __('Show: Albums', 'grand-media');
127
- break;
128
- case 'gmedia_filter':
129
- $button_title = __('Show: Filters', 'grand-media');
130
- break;
131
- case 'gmedia_tag':
132
- $button_title = __('Show: Tags', 'grand-media');
133
- break;
134
- case 'gmedia_category':
135
- $button_title = __('Show: Categories', 'grand-media');
136
- break;
137
- default:
138
- $button_title = __('Show: Albums', 'grand-media');
139
- break;
140
- }
141
- ?>
142
- <div class="btn-group" style="margin-right:20px;">
143
- <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
144
- <?php echo $button_title ?> <span class="caret"></span>
145
- </button>
146
- <ul class="dropdown-menu" role="menu">
147
- <li<?php echo ('gmedia_album' == $taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('term' => 'gmedia_album'), $url); ?>"><?php _e('Albums', 'grand-media'); ?></a></li>
148
- <li<?php echo ('gmedia_tag' == $taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('term' => 'gmedia_tag'), $url); ?>"><?php _e('Tags', 'grand-media'); ?></a></li>
149
- <li<?php echo ('gmedia_category' == $taxonomy)? ' class="active"' : '';?>><a href="<?php echo add_query_arg(array('term' => 'gmedia_category'), $url); ?>"><?php _e('Categories', 'grand-media'); ?></a></li>
150
- <li class="divider"></li>
151
- <li<?php echo ('gmedia_filter' == $taxonomy)? ' class="active"' : ''; ?>><a href="<?php echo add_query_arg(array('term' => 'gmedia_filter'), $url); ?>"><?php _e('Custom Filters', 'grand-media'); ?></a></li>
152
- </ul>
153
- </div>
154
-
155
- <?php if (('gmedia_filter' == $taxonomy) && $gmCore->caps['gmedia_filter_manage']) { ?>
156
- <a class="btn btn-success pull-left" href="<?php echo add_query_arg(array('edit_filter' => '0'), $url); ?>"><?php _e('Create Filter', 'grand-media'); ?></a>
157
- <?php } ?>
158
-
159
- <?php if (('gmedia_category' != $taxonomy) && ! empty($gmediaTerms)) { ?>
160
- <div class="btn-group">
161
- <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
162
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
163
- <span class="caret"></span>
164
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
165
- </button>
166
- <?php
167
- $rel_selected_show = 'rel-selected-show';
168
- $rel_selected_hide = 'rel-selected-hide';
169
- ?>
170
- <ul class="dropdown-menu" role="menu">
171
- <li class="dropdown-header <?php echo $rel_selected_hide; ?>"><span><?php _e("Select items to see more actions", "grand-media"); ?></span></li>
172
- <li class="<?php echo $rel_selected_show . ($gmCore->caps['gmedia_terms_delete']? '' : ' disabled'); ?>">
173
- <a href="<?php echo wp_nonce_url($gmCore->get_admin_url(array('delete' => 'selected'), array('filter')), 'gmedia_delete') ?>" class="gmedia-delete" data-confirm="<?php _e("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media"); ?>"><?php _e('Delete Selected Items', 'grand-media'); ?></a>
174
- </li>
175
- <?php do_action('gmedia_term_action_list'); ?>
176
- </ul>
177
- </div>
178
-
179
- <form class="btn-group" id="gm-selected-btn" name="gm-selected-form" action="<?php echo add_query_arg(array( 'term' => $taxonomy, 'filter' => 'selected'), $url); ?>" method="post">
180
- <button type="submit" class="btn btn<?php echo ('selected' == $gmCore->_req('filter')) ? '-success' : '-info' ?>"><?php printf(__('%s selected', 'grand-media'), '<span id="gm-selected-qty">' . count($gmProcessor->selected_items) . '</span>'); ?></button>
181
- <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"><span class="caret"></span> <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span></button>
182
- <input type="hidden" id="gm-selected" data-userid="<?php echo $user_ID; ?>" data-key="<?php echo $taxonomy; ?>" name="selected_items" value="<?php echo implode(',', $gmProcessor->selected_items); ?>"/>
183
- <ul class="dropdown-menu" role="menu">
184
- <li><a id="gm-selected-show" href="#show"><?php _e('Show only selected items', 'grand-media'); ?></a></li>
185
- <li><a id="gm-selected-clear" href="#clear"><?php _e('Clear selected items', 'grand-media'); ?></a></li>
186
- </ul>
187
- </form>
188
- <?php } ?>
189
-
190
- </div>
191
- </div>
192
-
193
-
194
- <?php if ('gmedia_album' == $taxonomy) { ?>
195
- <?php if ($allow_edit) { ?>
196
- <form method="post" id="gmedia-edit-term" name="gmAddTerms" class="panel-body" action="<?php echo $url; ?>" style="padding-bottom:0; border-bottom:1px solid #ddd;">
197
- <div class="row">
198
- <div class="col-xs-6">
199
- <div class="form-group">
200
- <label><?php _e('Name', 'grand-media'); ?></label>
201
- <input type="text" class="form-control input-sm" name="term[name]" placeholder="<?php _e('Album Name', 'grand-media'); ?>" required/>
202
- </div>
203
- <div class="form-group">
204
- <label><?php _e('Description', 'grand-media'); ?></label>
205
- <textarea class="form-control input-sm" style="height:75px;" rows="2" name="term[description]"></textarea>
206
- </div>
207
- </div>
208
- <div class="col-xs-6">
209
- <div class="form-group row">
210
- <div class="col-xs-6">
211
- <label><?php _e('Order gmedia', 'grand-media'); ?></label>
212
- <select name="term[meta][_orderby]" class="form-control input-sm">
213
- <option value="custom"><?php _e('user defined', 'grand-media'); ?></option>
214
- <option selected="selected" value="ID"><?php _e('by ID', 'grand-media'); ?></option>
215
- <option value="title"><?php _e('by title', 'grand-media'); ?></option>
216
- <option value="gmuid"><?php _e('by filename', 'grand-media'); ?></option>
217
- <option value="date"><?php _e('by date', 'grand-media'); ?></option>
218
- <option value="modified"><?php _e('by last modified date', 'grand-media'); ?></option>
219
- <option value="rand"><?php _e('Random', 'grand-media'); ?></option>
220
- </select>
221
- </div>
222
- <div class="col-xs-6">
223
- <label><?php _e('Sort order', 'grand-media'); ?></label>
224
- <select name="term[meta][_order]" class="form-control input-sm">
225
- <option selected="selected" value="DESC"><?php _e('DESC', 'grand-media'); ?></option>
226
- <option value="ASC"><?php _e('ASC', 'grand-media'); ?></option>
227
- </select>
228
- </div>
229
- </div>
230
- <div class="row">
231
- <div class="form-group col-xs-6">
232
- <label><?php _e('Status', 'grand-media'); ?></label>
233
- <select name="term[status]" class="form-control input-sm">
234
- <option selected="selected" value="public"><?php _e('Public', 'grand-media'); ?></option>
235
- <option value="private"><?php _e('Private', 'grand-media'); ?></option>
236
- <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
237
- </select>
238
- </div>
239
- <div class="col-xs-6">
240
- <div class="form-group">
241
- <label><?php _e('Author', 'grand-media'); ?></label>
242
- <?php $user_ids = $gmCore->caps['gmedia_delete_others_media'] ? $gmCore->get_editable_user_ids() : array($user_ID);
243
- if ($user_ids && $gmCore->caps['gmedia_edit_others_media']) {
244
- if (! in_array($user_ID, $user_ids)) {
245
- array_push($user_ids, $user_ID);
246
- }
247
- wp_dropdown_users(array(
248
- 'include' => $user_ids,
249
- 'include_selected' => true,
250
- 'name' => 'term[global]',
251
- 'selected' => $user_ID,
252
- 'class' => 'form-control input-sm',
253
- 'multi' => true,
254
- 'show_option_all' => __('Shared', 'grand-media')
255
- ));
256
- } else {
257
- echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
258
- echo '<div>' . get_the_author_meta('display_name', $user_ID) . '</div>';
259
- }
260
- ?>
261
- </div>
262
- <div class="form-group">
263
- <?php
264
- wp_original_referer_field(true, 'previous');
265
- wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
266
- ?>
267
- <input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
268
- <button style="display:block" type="submit" class="btn btn-primary btn-sm" name="gmedia_album_save"><?php _e('Add New Album', 'grand-media'); ?></button>
269
- </div>
270
- </div>
271
- </div>
272
- </div>
273
- </div>
274
- </form>
275
- <?php } else { ?>
276
- <div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
277
- <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only"><?php _e('Close', 'grand-media'); ?></span> </button>
278
- <strong><?php _e('Info:', 'grand-media'); ?></strong> <?php _e('You are not allowed to add new terms', 'grand-media'); ?>
279
- </div>
280
- <?php } ?>
281
- <form class="list-group <?php echo $taxonomy; ?>" id="gm-list-table" style="margin-bottom:4px;">
282
- <?php
283
- if (count($gmediaTerms)) {
284
- foreach ($gmediaTerms as $item) {
285
- $termItems = array();
286
- $per_page = 7;
287
- if ($item->count) {
288
- $term_meta = $gmDB->get_metadata('gmedia_term', $item->term_id);
289
- $term_meta = array_map('reset', $term_meta);
290
- $term_meta = array_merge(array('_orderby' => 'ID', '_order' => 'DESC'), $term_meta);
291
- $args = array(
292
- 'no_found_rows' => true,
293
- 'per_page' => $per_page,
294
- 'album__in' => array($item->term_id),
295
- 'author' => $author,
296
- 'orderby' => $term_meta['_orderby'],
297
- 'order' => $term_meta['_order']
298
- );
299
- $termItems = $gmDB->get_gmedias($args);
300
- }
301
- $is_selected = in_array($item->term_id, $gmProcessor->selected_items) ? true : false;
302
- $author_name = '';
303
- $list_row_class = $row_class = '';
304
- $allow_terms_delete = $gmCore->caps['gmedia_terms_delete'];
305
- if ($item->global) {
306
- if (($display_author_name = get_the_author_meta('display_name', $item->global))) {
307
- $author_name .= sprintf(__('by %s', 'grand-media'), $display_author_name);
308
- } else {
309
- $author_name .= '(' . __('deleted author', 'grand-media') . ')';
310
- }
311
- if ($item->global == $user_ID) {
312
- $row_class .= ' current_user';
313
- $allow_edit = $gmCore->caps['gmedia_album_manage'];
314
- $allow_delete = $allow_terms_delete;
315
- } else {
316
- $row_class .= ' other_user';
317
- $allow_edit = $gmCore->caps['gmedia_edit_others_media'];
318
- $allow_delete = ($allow_edit && $allow_terms_delete);
319
- }
320
- } else {
321
- $author_name .= '(' . __('no author', 'grand-media') . ')';
322
- $row_class .= ' shared';
323
- $allow_edit = $gmCore->caps['gmedia_edit_others_media'];
324
- $allow_delete = ($allow_edit && $allow_terms_delete);
325
- }
326
- if ('public' != $item->status) {
327
- $author_name .= ' [' . $item->status . ']';
328
- if ('private' == $item->status) {
329
- $list_row_class = ' list-group-item-info';
330
- } elseif ('draft' == $item->status) {
331
- $list_row_class = ' list-group-item-warning';
332
- }
333
- }
334
- ?>
335
- <div class="cb_list-item list-group-item term-list-item<?php echo ($is_selected ? ' gm-selected' : '') . $list_row_class; ?>">
336
- <div class="row cb_term-object<?php echo $row_class; ?>">
337
- <div class="term_id">#<?php echo $item->term_id; ?></div>
338
- <div class="col-xs-6 term-label">
339
- <div class="checkbox">
340
- <input name="doaction[]" type="checkbox"<?php echo $is_selected ? ' checked="checked"' : ''; ?> value="<?php echo $item->term_id; ?>"/>
341
- <?php if ($allow_edit) { ?>
342
- <a class="term_name" href="<?php echo add_query_arg(array('edit_album' => $item->term_id), $url); ?>"><?php echo esc_html($item->name); ?></a>
343
- <?php } else { ?>
344
- <span class="term_name"><?php echo esc_html($item->name); ?></span>
345
- <?php } ?>
346
- <span class="term_info_author"><?php echo $author_name; ?></span>
347
-
348
- <div class="object-actions">
349
- <?php
350
- if ($item->count) {
351
- $filter_href_attr = 'class="gm_filter_in_lib" href="' . $gmCore->get_admin_url(array( 'page' => 'GrandMedia', 'album__in' => $item->term_id), array(), true) . '"';
352
- } else {
353
- $filter_href_attr = 'class="gm_filter_in_lib action-inactive"';
354
- }
355
- echo '<a title="' . __('Filter in Gmedia Library', 'grand-media') . '" ' . $filter_href_attr . '><span class="gm_term_count">' . $item->count . '</span><span class="glyphicon glyphicon-filter"></span></a>';
356
-
357
- $cloud_link = $gmCore->gmcloudlink($item->term_id, 'album');
358
- $share_icon = '<span class="glyphicon glyphicon-share"></span>';
359
- if ('draft' !== $item->status) {
360
- echo '<a target="_blank" data-target="#shareModal" data-share="' . $item->term_id . '" class="share-modal" title="' . __('Share', 'grand-media') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
361
- } else {
362
- echo "<span class='action-inactive'>$share_icon</span>";
363
- }
364
-
365
- $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
366
- if ($allow_edit) {
367
- echo '<a title="' . __('Edit', 'grand-media') . '" href="' . add_query_arg(array('edit_album' => $item->term_id), $url) . '">' . $edit_icon . '</a>';
368
- } else {
369
- echo "<span class='action-inactive'>$edit_icon</span>";
370
- }
371
-
372
- if ($allow_terms_delete) {
373
- $trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
374
- if ($allow_delete) {
375
- echo '<a class="trash-icon" title="' . __('Delete', 'grand-media') . '" href="' . wp_nonce_url(add_query_arg(array( 'term' => $taxonomy, 'delete' => $item->term_id), $url), 'gmedia_delete') . '" data-confirm="' . __("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media") . '">' . $trash_icon . '</a>';
376
- } else {
377
- echo "<span class='action-inactive'>$trash_icon</span>";
378
- }
379
- }
380
- ?>
381
- </div>
382
- <?php if (! empty($item->description)) { ?>
383
- <div class="term-description"><?php echo esc_html(nl2br($item->description)); ?></div>
384
- <?php } ?>
385
- </div>
386
- </div>
387
- <div class="col-xs-6">
388
- <div class="term-images">
389
- <?php if (! empty($termItems)) {
390
- foreach ($termItems as $i) {
391
- ?>
392
- <img style="z-index:<?php echo $per_page--; ?>;" src="<?php echo $gmCore->gm_get_media_image($i, 'thumb', false); ?>" alt="<?php echo $i->ID; ?>" title="<?php echo esc_attr($i->title); ?>"/>
393
- <?php
394
- }
395
- }
396
- if (count($termItems) < $item->count) {
397
- echo '...';
398
- }
399
- ?>
400
- </div>
401
- </div>
402
- </div>
403
- </div>
404
- <?php
405
- }
406
- } else {
407
- ?>
408
- <div class="list-group-item">
409
- <div class="well well-lg text-center">
410
- <h4><?php _e('No items to show.', 'grand-media'); ?></h4>
411
- </div>
412
- </div>
413
- <?php } ?>
414
- <?php
415
- wp_original_referer_field(true, 'previous');
416
- wp_nonce_field('GmediaTerms');
417
- ?>
418
- </form>
419
-
420
-
421
- <?php } elseif ('gmedia_filter' == $taxonomy) { ?>
422
- <form class="list-group" id="gm-list-table" style="margin-bottom:4px;">
423
- <?php
424
- if (count($gmediaTerms)) {
425
- foreach ($gmediaTerms as $item) {
426
- $term_query = $gmDB->get_metadata('gmedia_term', $item->term_id, '_query', true);
427
-
428
- $is_selected = in_array($item->term_id, $gmProcessor->selected_items) ? true : false;
429
- $author_name = '';
430
- $row_class = '';
431
- $allow_terms_delete = $gmCore->caps['gmedia_terms_delete'];
432
- if ($item->global) {
433
- if (($display_author_name = get_the_author_meta('display_name', $item->global))) {
434
- $author_name .= sprintf(__('by %s', 'grand-media'), $display_author_name);
435
- } else {
436
- $author_name .= '(' . __('deleted author', 'grand-media') . ')';
437
- }
438
- if ($item->global == $user_ID) {
439
- $row_class .= ' current_user';
440
- $allow_edit = $gmCore->caps['gmedia_filter_manage'];
441
- $allow_delete = $allow_terms_delete;
442
- } else {
443
- $row_class .= ' other_user';
444
- $allow_edit = $gmCore->caps['gmedia_edit_others_media'];
445
- $allow_delete = ($allow_edit && $allow_terms_delete);
446
- }
447
- } else {
448
- $author_name .= '(' . __('no author', 'grand-media') . ')';
449
- $row_class .= ' shared';
450
- $allow_edit = $gmCore->caps['gmedia_edit_others_media'];
451
- $allow_delete = ($allow_edit && $allow_terms_delete);
452
- }
453
- ?>
454
- <div class="cb_list-item list-group-item term-list-item<?php echo $is_selected ? ' gm-selected' : ''; ?>">
455
- <div class="row cb_term-object<?php echo $row_class; ?>">
456
- <div class="term_id">#<?php echo $item->term_id; ?></div>
457
- <div class="col-xs-6 term-label">
458
- <div class="checkbox">
459
- <input name="doaction[]" type="checkbox"<?php echo $is_selected ? ' checked="checked"' : ''; ?> value="<?php echo $item->term_id; ?>"/>
460
- <?php if ($allow_edit) { ?>
461
- <a class="term_name" href="<?php echo add_query_arg(array('edit_filter' => $item->term_id), $url); ?>"><?php echo esc_html($item->name); ?></a>
462
- <?php } else { ?>
463
- <span class="term_name"><?php echo esc_html($item->name); ?></span>
464
- <?php } ?>
465
- <span class="term_info_author"><?php echo $author_name; ?></span>
466
-
467
- <div class="object-actions">
468
- <?php
469
- $filter_icon = '<span class="glyphicon glyphicon-filter"></span>';
470
- echo '<a title="' . __('Filter in Gmedia Library', 'grand-media') . '" href="' . $gmCore->get_admin_url(array( 'page' => 'GrandMedia', 'custom_filter' => $item->term_id), array(), true) . '">' . $filter_icon . '</a>';
471
-
472
- $cloud_link = $gmCore->gmcloudlink($item->term_id, 'filter');
473
- $share_icon = '<span class="glyphicon glyphicon-share"></span>';
474
- echo '<a target="_blank" data-target="#shareModal" data-share="' . $item->term_id . '" class="share-modal" title="' . __('Share', 'grand-media') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
475
-
476
- $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
477
- if ($allow_edit) {
478
- echo '<a title="' . __('Edit', 'grand-media') . '" href="' . add_query_arg(array('edit_filter' => $item->term_id), $url) . '">' . $edit_icon . '</a>';
479
- } else {
480
- echo "<span class='action-inactive'>$edit_icon</span>";
481
- }
482
-
483
- if ($allow_terms_delete) {
484
- $trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
485
- if ($allow_delete) {
486
- echo '<a class="trash-icon" title="' . __('Delete', 'grand-media') . '" href="' . wp_nonce_url(add_query_arg(array( 'term' => $taxonomy, 'delete' => $item->term_id), $url), 'gmedia_delete') . '" data-confirm="' . __("You are about to permanently delete the selected items.\n\r'Cancel' to stop, 'OK' to delete.", "grand-media") . '">' . $trash_icon . '</a>';
487
- } else {
488
- echo "<span class='action-inactive'>$trash_icon</span>";
489
- }
490
- }
491
- ?>
492
- </div>
493
- </div>
494
- </div>
495
- <div class="col-xs-6">
496
- <p class="term-meta" style="margin:10px 0;">
497
- <?php echo '<b>' . __('Query:') . "</b> " . str_replace(',"', ', "', json_encode($term_query)); ?>
498
- </p>
499
- </div>
500
- </div>
501
- <?php if (! empty($item->description)) { ?>
502
- <div class="term-description"><?php echo nl2br(esc_html($item->description)); ?></div>
503
- <?php } ?>
504
- </div>
505
- <?php
506
- }
507
- } else {
508
- ?>
509
- <div class="list-group-item">
510
- <div class="well well-lg text-center">
511
- <h4><?php _e('No items to show.', 'grand-media'); ?></h4>
512
- </div>
513
- </div>
514
- <?php } ?>
515
- <?php
516
- wp_original_referer_field(true, 'previous');
517
- wp_nonce_field('GmediaTerms');
518
- ?>
519
- </form>
520
-
521
-
522
- <?php } elseif ('gmedia_tag' == $taxonomy) { ?>
523
- <?php if ($allow_edit) { ?>
524
- <form method="post" id="gmedia-edit-term" name="gmAddTerms" class="panel-body" action="<?php echo add_query_arg(array('term' => $taxonomy), $url); ?>" style="padding-bottom:0; border-bottom:1px solid #ddd;">
525
- <div class="row">
526
- <div class="form-group col-xs-9">
527
- <label><?php _e('Tags', 'grand-media'); ?>
528
- <small class="text-muted">(<?php _e('you can type multiple tags separated by comma') ?>)</small>
529
- </label>
530
- <input type="text" class="form-control input-sm" name="term[name]" placeholder="<?php _e('Tag Names', 'grand-media'); ?>" required/>
531
- </div>
532
- <div class="col-xs-3" style="padding-top:24px;">
533
- <?php
534
- wp_original_referer_field(true, 'previous');
535
- wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
536
- ?>
537
- <input type="hidden" name="term[taxonomy]" value="gmedia_tag"/>
538
- <button type="submit" class="btn btn-primary btn-sm" name="gmedia_tag_add"><?php _e('Add New Tags', 'grand-media'); ?></button>
539
- </div>
540
- </div>
541
- </form>
542
- <?php } else { ?>
543
- <div class="alert alert-warning alert-dismissible" role="alert" style="margin-bottom:0">
544
- <button type="button" class="close" data-dismiss="alert">
545
- <span aria-hidden="true">&times;</span><span class="sr-only"><?php _e('Close', 'grand-media'); ?></span>
546
- </button>
547
- <strong><?php _e('Info:', 'grand-media'); ?></strong> <?php _e('You are not allowed to add new terms', 'grand-media'); ?>
548
- </div>
549
- <?php } ?>
550
- <form class="list-group" id="gm-list-table" style="margin-bottom:4px;">
551
- <?php
552
- if (count($gmediaTerms)) {
553
- if ($gmCore->caps['gmedia_edit_others_media']) {
554
- $allow_edit = true;
555
- $allow_delete = $gmCore->caps['gmedia_terms_delete'];
556
- } else {
557
- $allow_edit = false;
558
- $allow_delete = false;
559
- }
560
- foreach ($gmediaTerms as $item) {
561
- $termItems = array();
562
- $per_page = 5;
563
- if ($item->count) {
564
- $args = array(
565
- 'no_found_rows' => true,
566
- 'per_page' => $per_page,
567
- 'orderby' => $gmGallery->options['in_tag_orderby'],
568
- 'order' => $gmGallery->options['in_tag_order'],
569
- 'tag_id' => $item->term_id,
570
- 'author' => $author
571
- );
572
- $termItems = $gmDB->get_gmedias($args);
573
- }
574
- $is_selected = in_array($item->term_id, $gmProcessor->selected_items) ? true : false;
575
- ?>
576
- <div class="cb_list-item list-group-item term-list-item<?php echo $is_selected ? ' gm-selected' : ''; ?>">
577
- <div class="row cb_term-object" id="tag_<?php echo $item->term_id; ?>">
578
- <div class="term_id">#<?php echo $item->term_id; ?></div>
579
- <div class="col-xs-6 term-label">
580
- <div class="checkbox">
581
- <input name="doaction[]" type="checkbox"<?php echo $is_selected ? ' checked="checked"' : ''; ?> value="<?php echo $item->term_id; ?>"/>
582
- <?php if ($allow_edit) { ?>
583
- <a class="edit_tag_link" href="#tag_<?php echo $item->term_id; ?>"><?php echo esc_html($item->name); ?></a>
584
- <span class="edit_tag_form" style="display:none;"><input class="edit_tag_input" type="text" data-tag_id="<?php echo $item->term_id; ?>" name="gmedia_tag_name[<?php echo $item->term_id; ?>]" value="<?php echo esc_attr($item->name); ?>" placeholder="<?php echo esc_attr($item->name); ?>"/><a href="#tag_<?php echo $item->term_id; ?>" class="edit_tag_save btn btn-link glyphicon glyphicon-pencil"></a></span>
585
-
586
- <?php } else { ?>
587
- <span><?php echo esc_html($item->name); ?></span>
588
- <?php } ?>
589
-
590
- <div class="object-actions">
591
- <?php
592
- if ($item->count) {
593
- $filter_href_attr = 'class="gm_filter_in_lib" href="' . $gmCore->get_admin_url(array( 'page' => 'GrandMedia', 'tag__in' => $item->term_id), array(), true) . '"';
594
- } else {
595
- $filter_href_attr = 'class="gm_filter_in_lib action-inactive"';
596
- }
597
- echo '<a title="' . __('Filter in Gmedia Library', 'grand-media') . '" ' . $filter_href_attr . '><span class="gm_term_count">' . $item->count . '</span><span class="glyphicon glyphicon-filter"></span></a>';
598
-
599
- $cloud_link = $gmCore->gmcloudlink($item->term_id, 'tag');
600
- $share_icon = '<span class="glyphicon glyphicon-share"></span>';
601
- echo '<a target="_blank" data-target="#shareModal" data-share="' . $item->term_id . '" class="share-modal" title="' . __('Share', 'grand-media') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
602
-
603
- /*
604
- $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
605
- if ( $allow_edit ){
606
- echo '<a class="edit_tag_link" title="' . __('Edit', 'grand-media') . '" href="#tag_' . $item->term_id . '">'.$edit_icon.'</a>';
607
- }
608
- */
609
-
610
- if ($allow_delete) {
611
- $trash_icon = '<span class="glyphicon glyphicon-trash"></span>';
612
- echo '<a title="' . __('Delete', 'grand-media') . '" href="' . wp_nonce_url(add_query_arg(array( 'term' => $taxonomy, 'delete' => $item->term_id), $url), 'gmedia_delete') . '">' . $trash_icon . '</a>';
613
- }
614
- ?>
615
- </div>
616
- </div>
617
- </div>
618
- <div class="col-xs-6 term-images">
619
- <?php if (! empty($termItems)) {
620
- foreach ($termItems as $i) {
621
- ?>
622
- <img style="z-index:<?php echo $per_page--; ?>;" src="<?php echo $gmCore->gm_get_media_image($i, 'thumb', false); ?>" alt="<?php echo $i->ID; ?>" title="<?php echo esc_attr($i->title); ?>"/>
623
- <?php
624
- }
625
- }
626
- if (count($termItems) < $item->count) {
627
- echo '...';
628
- }
629
- ?>
630
- </div>
631
- </div>
632
- </div>
633
- <?php } ?>
634
- <?php if ($allow_edit){ ?>
635
- <script type="text/javascript">
636
- jQuery(function ($) {
637
- $('#gm-list-table').data('edit', false);
638
- $('input.edit_tag_input').keypress(function (e) {
639
- var tagdiv = $('#tag_' + $(this).data('tag_id'));
640
- var charCode = e.charCode || e.keyCode || e.which;
641
- if (charCode == 13) {
642
- e.preventDefault();
643
- edit_tag(tagdiv);
644
- }
645
- }).blur(function () {
646
- var tagdiv = $('#tag_' + $(this).data('tag_id'));
647
- edit_tag(tagdiv);
648
- });
649
-
650
- $('.edit_tag_link').click(function (e) {
651
- e.preventDefault();
652
- var id = $(this).attr('href');
653
- $(this).hide();
654
- $(id).find('.edit_tag_form').show().find('input').focus();
655
- $('#gm-list-table').data('edit', true);
656
- });
657
- $('.edit_tag_save').click(function (e) {
658
- e.preventDefault();
659
- });
660
-
661
- function edit_tag(tagdiv) {
662
- var inp = tagdiv.find('.edit_tag_form input');
663
- var new_tag_name = $.trim(inp.val());
664
- var old_tag_name = inp.attr('placeholder');
665
- if ((old_tag_name == new_tag_name) || ('' === new_tag_name) || $.isNumeric()) {
666
- inp.val(old_tag_name);
667
- tagdiv.find('.edit_tag_form').hide();
668
- tagdiv.find('.edit_tag_link').show();
669
- return;
670
- }
671
- var post_data = {
672
- action: 'gmedia_tag_edit',
673
- tag_id: inp.data('tag_id'),
674
- tag_name: new_tag_name,
675
- _wpnonce: $('#_wpnonce').val()
676
- };
677
- $.post(ajaxurl, post_data, function (data, textStatus, jqXHR) {
678
- console.log(data);
679
- if (data.error) {
680
- //inp.val(inp.attr('placeholder'));
681
- $('#gmedia-panel').before(data.error);
682
- } else {
683
- //new_tag_name = new_tag_name.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
684
- inp.attr('placeholder', new_tag_name);
685
- tagdiv.find('.edit_tag_link').text(new_tag_name).show();
686
- //noinspection JSUnresolvedVariable
687
- $('#gmedia-panel').before(data.msg);
688
- tagdiv.find('.edit_tag_form').hide();
689
- }
690
- });
691
- }
692
- });
693
- </script>
694
- <?php } ?>
695
- <?php
696
- } else {
697
- ?>
698
- <div class="list-group-item">
699
- <div class="well well-lg text-center">
700
- <h4><?php _e('No items to show.', 'grand-media'); ?></h4>
701
- </div>
702
- </div>
703
- <?php } ?>
704
- <?php
705
- wp_original_referer_field(true, 'previous');
706
- wp_nonce_field('GmediaTerms');
707
- ?>
708
- </form>
709
-
710
-
711
- <?php } elseif ('gmedia_category' == $taxonomy) { ?>
712
- <div class="panel-body"></div>
713
- <div class="list-group" id="gm-list-table" style="margin-bottom:4px;">
714
- <?php
715
- $gmediaCategories = $gmGallery->options['taxonomies']['gmedia_category'];
716
- foreach ($gmediaTerms as $item) {
717
- $cat[$item->name] = $item;
718
- }
719
- unset($gmediaTerms);
720
-
721
- foreach ($gmediaCategories as $name => $title) {
722
- $termItems = array();
723
- $per_page = 10;
724
- if (isset($cat[$name])) {
725
- $count = $cat[$name]->count;
726
- $term_id = $cat[$name]->term_id;
727
- if ($count) {
728
- $args = array(
729
- 'no_found_rows' => true,
730
- 'per_page' => $per_page,
731
- 'orderby' => $gmGallery->options['in_category_orderby'],
732
- 'order' => $gmGallery->options['in_category_order'],
733
- 'category__in' => array($term_id),
734
- 'author' => $author
735
- );
736
- $termItems = $gmDB->get_gmedias($args);
737
- }
738
- } else {
739
- $count = 0;
740
- $term_id = '##';
741
- }
742
- ?>
743
- <div class="list-group-item term-list-item">
744
- <div class="row cb_term-object">
745
- <div class="term_id">#<?php echo $term_id; ?></div>
746
- <div class="col-xs-6" style="padding-top:10px; padding-bottom:10px;">
747
- <?php echo esc_html($title); ?>
748
- <div class="object-actions">
749
- <?php
750
- if ($count) {
751
- $filter_href_attr = 'class="gm_filter_in_lib" href="' . $gmCore->get_admin_url(array( 'page' => 'GrandMedia', 'category__in' => $term_id), array(), true) . '"';
752
- } else {
753
- $filter_href_attr = 'class="gm_filter_in_lib action-inactive"';
754
- }
755
- echo '<a title="' . __('Filter in Gmedia Library', 'grand-media') . '" ' . $filter_href_attr . '><span class="gm_term_count">' . $count . '</span><span class="glyphicon glyphicon-filter"></span></a>';
756
-
757
- $share_icon = '<span class="glyphicon glyphicon-share"></span>';
758
- if (isset($cat[$name]->term_id)) {
759
- $cloud_link = $gmCore->gmcloudlink($term_id, 'category');
760
- echo '<a target="_blank" data-target="#shareModal" data-share="' . $term_id . '" class="share-modal" title="' . __('Share', 'grand-media') . '" href="' . $cloud_link . '">' . $share_icon . '</a>';
761
- } else {
762
- echo "<span class='action-inactive'>$share_icon</span>";
763
- }
764
-
765
- /*
766
- $edit_icon = '<span class="glyphicon glyphicon-edit"></span>';
767
- echo '<a title="' . __('Edit', 'grand-media') . '" href="' . add_query_arg( array( 'edit_album' => $item->term_id ), $url ) . '">'.$edit_icon.'</a>';
768
- */
769
- ?>
770
- </div>
771
- </div>
772
- <div class="col-xs-6 term-images">
773
- <?php if (! empty($termItems)) {
774
- foreach ($termItems as $i) {
775
- ?>
776
- <img style="z-index:<?php echo $per_page--; ?>;" src="<?php echo $gmCore->gm_get_media_image($i, 'thumb', false); ?>" alt="<?php echo $i->ID; ?>" title="<?php echo esc_attr($i->title); ?>"/>
777
- <?php
778
- }
779
- }
780
- if (count($termItems) < $count) {
781
- echo '...';
782
- }
783
- ?>
784
- </div>
785
- </div>
786
- </div>
787
- <?php } ?>
788
- </div>
789
- <?php } ?>
790
-
791
- </div>
792
-
793
- <div class="modal fade gmedia-modal" id="shareModal" tabindex="-1" role="dialog" aria-hidden="true">
794
- <div class="modal-dialog">
795
- <div class="modal-content">
796
- <div class="modal-header">
797
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
798
- <h4 class="modal-title"><?php _e('GmediaCloud Page'); ?></h4>
799
- </div>
800
- <form class="modal-body" method="post" id="shareForm">
801
- <div class="form-group">
802
- <label><?php _e('Link to page', 'grand-media'); ?></label>
803
- <input name="sharelink" type="text" class="form-control sharelink" readonly="readonly" value=""/>
804
- </div>
805
- <div class="form-group">
806
- <label><?php _e('Send this link to', 'grand-media'); ?></label>
807
- <input name="email" type="email" class="form-control sharetoemail" value="" placeholder="<?php _e('Email', 'grand-media'); ?>"/>
808
- <textarea name="message" cols="20" rows="3" class="form-control" placeholder="<?php _e('Message (optional)', 'grand-media'); ?>"></textarea>
809
- </div>
810
- <input type="hidden" name="action" value="gmedia_share_page"/>
811
- <?php wp_nonce_field('share_modal', '_sharenonce'); ?>
812
- </form>
813
- <div class="modal-footer">
814
- <button type="button" class="btn btn-primary sharebutton" disabled="disabled"><?php _e('Send', 'grand-media'); ?></button>
815
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
816
- </div>
817
- </div>
818
- </div>
819
- </div>
820
-
821
- <?php
822
- }
823
-
824
-
825
- /**
826
- * gmediaAlbumEdit()
827
- *
828
- * @return mixed content
829
- */
830
- function gmediaAlbumEdit()
831
- {
832
- global $gmDB, $gmCore, $gmProcessor, $gmGallery, $user_ID;
833
-
834
- if (! $gmCore->caps['gmedia_album_manage']) {
835
- die('-1');
836
- }
837
-
838
- $url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
839
-
840
- $gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
841
- if (! is_array($gm_screen_options)) {
842
- $gm_screen_options = array();
843
- }
844
- $gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);
845
-
846
- $taxonomy = 'gmedia_album';
847
- $term_id = $gmCore->_get('edit_album');
848
-
849
- $term = $gmDB->get_term($term_id, $taxonomy);
850
-
851
- if (! empty($term) && ! is_wp_error($term)) {
852
-
853
- $term_meta = $gmDB->get_metadata('gmedia_term', $term->term_id);
854
- $term_meta = array_map('reset', $term_meta);
855
- $term_meta = array_merge(array('_cover' => '', '_orderby' => 'ID', '_order' => 'DESC'), $term_meta);
856
- $per_page = ! empty($gm_screen_options['per_page_sort_gmedia']) ? $gm_screen_options['per_page_sort_gmedia'] : 60;
857
- $cur_page = $gmCore->_get('pager', 1);
858
- $pager_html = '';
859
-
860
- $termItems = array();
861
- if ($term->count) {
862
- $args = array(
863
- 'album__in' => $term->term_id,
864
- 'orderby' => $term_meta['_orderby'],
865
- 'order' => $term_meta['_order'],
866
- 'per_page' => $per_page,
867
- 'page' => $cur_page
868
- );
869
- $termItems = $gmDB->get_gmedias($args);
870
-
871
- $pager_html = $gmDB->query_pager();
872
- }
873
-
874
- ?>
875
- <div class="panel panel-default">
876
- <div class="panel-heading clearfix">
877
- <div class="btn-toolbar pull-left">
878
- <div class="btn-group" style="margin-right:20px;">
879
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
880
- <?php _e('Return to') ?> <span class="caret"></span>
881
- </button>
882
- <ul class="dropdown-menu" role="menu">
883
- <li class="active"><a href="<?php echo add_query_arg(array('term' => 'gmedia_album'), $url); ?>"><?php _e('Albums', 'grand-media'); ?></a></li>
884
- <li><a href="<?php echo add_query_arg(array('term' => 'gmedia_tag'), $url); ?>"><?php _e('Tags', 'grand-media'); ?></a></li>
885
- <li><a href="<?php echo add_query_arg(array('term' => 'gmedia_category'), $url); ?>"><?php _e('Categories', 'grand-media'); ?></a></li>
886
- <li class="divider"></li>
887
- <li><a href="<?php echo add_query_arg(array('term' => 'gmedia_filter'), $url); ?>"><?php _e('Custom Filters', 'grand-media'); ?></a></li>
888
- </ul>
889
- </div>
890
-
891
- <div class="btn-group">
892
- <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
893
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
894
- <span class="caret"></span>
895
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
896
- </button>
897
- <ul class="dropdown-menu" role="menu">
898
- <li><a href="<?php echo add_query_arg(array( 'page' => 'GrandMedia', 'alb' => $term->term_id), admin_url('admin.php')); ?>"><?php _e('Show Album in Gmedia Library', 'grand-media'); ?></a> </li>
899
- </ul>
900
- </div>
901
- </div>
902
-
903
- </div>
904
-
905
- <form method="post" id="gmedia-edit-term" name="gmEditTerm" class="panel-body" data-id="<?php echo $term->term_id; ?>">
906
- <h4 style="margin-top:0;">
907
- <span class="pull-right"><?php echo __('ID', 'grand-media') . ": {$term->term_id}"; ?></span>
908
- <?php _e('Edit Album'); ?>: <em><?php echo esc_html($term->name); ?></em>
909
- </h4>
910
-
911
- <div class="row">
912
- <div class="col-xs-6">
913
- <div class="form-group row">
914
- <div class="col-xs-6">
915
- <label><?php _e('Name', 'grand-media'); ?></label>
916
- <input type="text" class="form-control input-sm" name="term[name]" value="<?php echo esc_attr($term->name); ?>" placeholder="<?php _e('Album Name', 'grand-media'); ?>" required/>
917
- </div>
918
- <div class="col-xs-6">
919
- <label><?php _e('Author', 'grand-media'); ?></label>
920
- <?php $user_ids = $gmCore->caps['gmedia_delete_others_media'] ? $gmCore->get_editable_user_ids() : array($user_ID);
921
- if ($user_ids && $gmCore->caps['gmedia_edit_others_media']) {
922
- if (! in_array($user_ID, $user_ids)) {
923
- array_push($user_ids, $user_ID);
924
- }
925
- $selected_user = get_the_author_meta('display_name', $term->global) ? $term->global : 0;
926
- wp_dropdown_users(array(
927
- 'include' => $user_ids,
928
- 'include_selected' => true,
929
- 'name' => 'term[global]',
930
- 'selected' => $selected_user,
931
- 'class' => 'form-control input-sm',
932
- 'multi' => true,
933
- 'show_option_all' => __('Shared', 'grand-media')
934
- ));
935
- } else {
936
- echo '<input type="hidden" name="term[global]" value="' . $user_ID . '"/>';
937
- echo '<div>' . get_the_author_meta('display_name', $user_ID) . '</div>';
938
- }
939
- ?>
940
- </div>
941
- </div>
942
- <div class="form-group">
943
- <label><?php _e('Description', 'grand-media'); ?></label>
944
- <textarea class="form-control input-sm" style="height:53px;" rows="2" name="term[description]"><?php echo $term->description; ?></textarea>
945
- </div>
946
- <div class="text-right">
947
- <?php wp_nonce_field('GmediaTerms', 'term_save_wpnonce'); ?>
948
- <input type="hidden" name="term[term_id]" value="<?php echo $term->term_id; ?>"/>
949
- <input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
950
- <button type="submit" class="btn btn-primary btn-sm" name="gmedia_album_save"><?php _e('Update', 'grand-media'); ?></button>
951
- </div>
952
- </div>
953
- <div class="col-xs-6">
954
- <div class="row">
955
- <div class="col-xs-6">
956
- <div class="form-group">
957
- <label><?php _e('Status', 'grand-media'); ?></label>
958
- <select name="term[status]" class="form-control input-sm">
959
- <option value="public"<?php selected($term->status, 'public'); ?>><?php _e('Public', 'grand-media'); ?></option>
960
- <option value="private"<?php selected($term->status, 'private'); ?>><?php _e('Private', 'grand-media'); ?></option>
961
- <option value="draft"<?php selected($term->status, 'draft'); ?>><?php _e('Draft', 'grand-media'); ?></option>
962
- </select>
963
- </div>
964
- <div class="form-group">
965
- <div class="checkbox"><label><input type="checkbox" name="term[status_global]" value="1"> <?php _e('Apply Status for all items in album', 'grand-media'); ?> </label></div>
966
- </div>
967
- </div>
968
- <div class="col-xs-6">
969
- <div class="form-group">
970
- <label><?php _e('Album Cover', 'grand-media'); ?></label>
971
- <input type="text" class="form-control input-sm" name="term[meta][_cover]" value="<?php echo esc_attr($term_meta['_cover']); ?>" placeholder="<?php _e('Gmedia Image ID', 'grand-media'); ?>"/>
972
- </div>
973
- <?php if ($term_meta['_cover']) {
974
- $cover_id = intval($term_meta['_cover']);
975
- if (($cover = $gmDB->get_gmedia($cover_id))) { ?>
976
- <div class="gm-img-thumbnail" data-gmid="<?php echo $cover->ID; ?>"><?php
977
- ?><img src="<?php echo $gmCore->gm_get_media_image($cover, 'thumb', true); ?>" alt="<?php echo $cover->ID; ?>" title="<?php echo esc_attr($cover->title); ?>"/><?php
978
- ?><span class="label label-default">ID: <?php echo $cover->ID; ?></span><?php
979
- ?></div>
980
- <?php } else {
981
- echo '<strong class="text-danger">' . __('No image with such ID', 'grand-media') . '</strong>';
982
- }
983
- } ?>
984
- </div>
985
- </div>
986
- </div>
987
- </div>
988
- <hr/>
989
- <?php
990
- $gmCore->gmedia_custom_meta_box($term->term_id, $meta_type = 'gmedia_term');
991
- do_action('gmedia_term_edit_form');
992
- ?>
993
- </form>
994
- </div>
995
- <div class="panel panel-default">
996
- <div class="panel-heading clearfix">
997
- <h4 style="margin:7px 0;" class="pull-left"><?php _e('Sort Album'); ?></h4>
998
-
999
- <?php echo $pager_html; ?>
1000
-
1001
- </div>
1002
- <form method="post" id="gmedia-sort-term" name="gmSortTerm" class="panel-body">
1003
- <div class="order-form" style="border-bottom:1px solid #ddd; margin-bottom:15px;">
1004
- <div class="row">
1005
- <div class="col-xs-3">
1006
- <div class="form-group">
1007
- <label><?php _e('Order gmedia', 'grand-media'); ?></label>
1008
- <select name="term[meta][_orderby]" id="gmedia_term_orderby" class="form-control input-sm">
1009
- <option value="custom"<?php selected($term_meta['_orderby'], 'custom'); ?>><?php _e('Custom Order', 'grand-media'); ?></option>
1010
- <option value="ID"<?php selected($term_meta['_orderby'], 'ID'); ?>><?php _e('by ID', 'grand-media'); ?></option>
1011
- <option value="title"<?php selected($term_meta['_orderby'], 'title'); ?>><?php _e('by title', 'grand-media'); ?></option>
1012
- <option value="gmuid"<?php selected($term_meta['_orderby'], 'gmuid'); ?>><?php _e('by filename', 'grand-media'); ?></option>
1013
- <option value="date"<?php selected($term_meta['_orderby'], 'date'); ?>><?php _e('by date', 'grand-media'); ?></option>
1014
- <option value="modified"<?php selected($term_meta['_orderby'], 'modified'); ?>><?php _e('by last modified date', 'grand-media'); ?></option>
1015
- <option value="rand"<?php selected($term_meta['_orderby'], 'rand'); ?>><?php _e('Random', 'grand-media'); ?></option>
1016
- </select>
1017
- </div>
1018
- </div>
1019
- <div class="col-xs-3">
1020
- <div class="form-group">
1021
- <label><?php _e('Sort order', 'grand-media'); ?></label>
1022
- <select id="gmedia_term_order" name="term[meta][_order]" class="form-control input-sm">
1023
- <option value="DESC"<?php selected($term_meta['_order'], 'DESC'); ?>><?php _e('DESC', 'grand-media'); ?></option>
1024
- <option value="ASC"<?php selected($term_meta['_order'], 'ASC'); ?>><?php _e('ASC', 'grand-media'); ?></option>
1025
- </select>
1026
- </div>
1027
- </div>
1028
- <div class="col-xs-6">
1029
- <div class="form-group pull-left" style="margin-right:30px;">
1030
- <label style="visibility:hidden;">-</label>
1031
-
1032
- <div class="checkbox"><label><input id="reset_order_option" type="checkbox" name="term[reset_custom_order]" value="1"> <?php _e('Reset custom order', 'grand-media'); ?> </label></div>
1033
- </div>
1034
- <div class="form-group pull-left">
1035
- <label style="visibility:hidden;">-</label>
1036
- <button style="display:block" type="submit" class="btn btn-primary btn-sm" name="gmedia_term_sort_save"><?php _e('Update', 'grand-media'); ?></button>
1037
- </div>
1038
- <?php wp_nonce_field('GmediaTerms', 'term_save_wpnonce'); ?>
1039
- <input type="hidden" name="term[term_id]" value="<?php echo $term->term_id; ?>"/>
1040
- <input type="hidden" name="term[taxonomy]" value="gmedia_album"/>
1041
- </div>
1042
- </div>
1043
- <p><?php _e('Use your mouse (drag&drop) for custom sorting of images or manually enter index number in top right field of each image.') ?></p>
1044
- </div>
1045
- <div class="termItems clearfix" id="termItems">
1046
- <?php if (! empty($termItems)) {
1047
- foreach ($termItems as $item) {
1048
- ?>
1049
- <div class="gm-img-thumbnail" data-gmid="<?php echo $item->ID; ?>"><?php
1050
- ?><img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt="<?php echo $item->ID; ?>" title="<?php echo esc_attr($item->title); ?>"/><?php
1051
- ?><input type="text" name="term[gmedia_ids][<?php echo $item->ID; ?>]" value="<?php echo isset($item->gmedia_order) ? $item->gmedia_order : '0'; ?>"/><?php
1052
- ?><span class="label label-default">ID: <?php echo $item->ID; ?></span><?php
1053
- ?><div class="gm-img-thumb-title"><?php echo esc_html($item->title); ?></div>
1054
- </div>
1055
- <?php
1056
- }
1057
- } ?>
1058
-
1059
- </div>
1060
- </form>
1061
- <div class="panel-footer clearfix" style="margin-top:20px;"><?php echo $pager_html; ?>
1062
- <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $term->count); ?></div>
1063
- </div>
1064
-
1065
- <script type="text/javascript">
1066
- jQuery(function ($) {
1067
- var sortdiv = $('#termItems');
1068
- var items = $('.gm-img-thumbnail', sortdiv);
1069
-
1070
- sortdiv.sortable({
1071
- items: '.gm-img-thumbnail',
1072
- handle: 'img',
1073
- placeholder: 'gm-img-thumbnail ui-highlight-placeholder',
1074
- forcePlaceholderSize: true,
1075
- //revert: true,
1076
- stop: function (event, ui) {
1077
- $('#gmedia_term_orderby').val('custom');
1078
- var cur_order, prev_order, next_order;
1079
- var self = ui.item,
1080
- prev_item = self.prev(),
1081
- next_item = self.next();
1082
- prev_order = prev_item.length ? parseInt($('input', prev_item).val()) : 0;
1083
- var img_order_asc = ('ASC' == $('#gmedia_term_order').val());
1084
- if (img_order_asc) {
1085
- cur_order = prev_order + 1;
1086
- $('input', self).val(cur_order);
1087
- while (next_item.length) {
1088
- next_order = parseInt(next_item.find('input').val());
1089
- if (cur_order < next_order) {
1090
- break;
1091
- }
1092
- cur_order += 1;
1093
- next_item.find('input').val(cur_order);
1094
- next_item = next_item.next();
1095
- }
1096
-
1097
- } else {
1098
- next_order = next_item.length ? parseInt($('input', next_item).val()) : (prev_order ? (prev_order - 1) : 0);
1099
- cur_order = next_order + 1;
1100
- $('input', self).val(cur_order);
1101
- while (prev_item.length) {
1102
- prev_order = parseInt(prev_item.find('input').val());
1103
- if (cur_order < prev_order) {
1104
- break;
1105
- }
1106
- cur_order += 1;
1107
- prev_item.find('input').val(cur_order);
1108
- prev_item = prev_item.prev();
1109
- }
1110
- }
1111
- }
1112
- });
1113
-
1114
- $('input', items).on('change', function () {
1115
- $('#gmedia_term_orderby').val('custom');
1116
- sortdiv.css({height: sortdiv.height()});
1117
- var items = $('.gm-img-thumbnail', sortdiv);
1118
-
1119
- var new_order = $.isNumeric($(this).val()) ? parseInt($(this).val()) : -1;
1120
- $(this).val(new_order).closest('.gm-img-thumbnail').css({zIndex: 1000});
1121
-
1122
- var ipos = [];
1123
- items.each(function (i, el) {
1124
- var pos = $(el).position();
1125
- $.data(el, 'pos', pos);
1126
- ipos[i] = pos;
1127
- });
1128
-
1129
- var img_order_asc = ('ASC' == $('#gmedia_term_order').val());
1130
- var order = img_order_asc ? 'asc' : 'desc';
1131
- items.tsort('input', {
1132
- useVal: true,
1133
- order: order
1134
- }, 'span.label', {order: order}).each(function (i, el) {
1135
- var from = $.data(el, 'pos');
1136
- var to = ipos[i];
1137
- $(el).css({position: 'absolute', top: from.top, left: from.left}).animate({
1138
- top: to.top,
1139
- left: to.left
1140
- }, 500);
1141
- }).promise().done(function () {
1142
- items.removeAttr('style');
1143
- sortdiv.removeAttr('style');
1144
- });
1145
-
1146
- $(this).val(((0 > new_order) ? 0 : new_order));
1147
- });
1148
- });
1149
- </script>
1150
-
1151
- </div>
1152
-
1153
-
1154
- <div class="modal fade gmedia-modal" id="newCustomFieldModal" tabindex="-1" role="dialog" aria-hidden="true">
1155
- <div class="modal-dialog">
1156
- <div class="modal-content">
1157
- <div class="modal-header">
1158
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
1159
- <h4 class="modal-title"><?php _e('Add New Custom Field'); ?></h4>
1160
- </div>
1161
- <form class="modal-body" method="post" id="newCustomFieldForm">
1162
- <?php
1163
- echo $gmCore->meta_form($meta_type = 'gmedia_term');
1164
- wp_nonce_field('gmedia_custom_field', '_customfield_nonce');
1165
- ?>
1166
- <input type="hidden" name="action" value="gmedia_term_add_custom_field"/>
1167
- <input type="hidden" class="newcustomfield-for-id" name="ID" value=""/>
1168
- </form>
1169
- <div class="modal-footer">
1170
- <button type="button" class="btn btn-primary customfieldsubmit"><?php _e('Add', 'grand-media'); ?></button>
1171
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Close', 'grand-media'); ?></button>
1172
- </div>
1173
- </div>
1174
- </div>
1175
- </div>
1176
- <?php
1177
- } else {
1178
-
1179
- }
1180
- }
1181
-
1182
- /**
1183
- * gmediaFilterEdit()
1184
- *
1185
- * @return mixed content
1186
- */
1187
- function gmediaFilterEdit()
1188
- {
1189
- global $gmDB, $gmCore, $gmProcessor, $gmGallery, $user_ID;
1190
-
1191
- if (! $gmCore->caps['gmedia_filter_manage']) {
1192
- die('-1');
1193
- }
1194
-
1195
- $url = add_query_arg(array('page' => $gmProcessor->page), admin_url('admin.php'));
1196
-
1197
- /*$gm_screen_options = get_user_meta($user_ID, 'gm_screen_options', true);
1198
- if(!is_array($gm_screen_options)){
1199
- $gm_screen_options = array();
1200
- }
1201
- $gm_screen_options = array_merge($gmGallery->options['gm_screen_options'], $gm_screen_options);*/
1202
- //$per_page = !empty($gm_screen_options['per_page_sort_gmedia'])? $gm_screen_options['per_page_sort_gmedia'] : 40;
1203
- $per_page = 40;
1204
- $cur_page = $gmCore->_get('pager', 1);
1205
-
1206
- $taxonomy = 'gmedia_filter';
1207
- $term_id = (int)$gmCore->_get('edit_filter');
1208
-
1209
- $author_new = false;
1210
- if ($gmCore->caps['gmedia_edit_others_media']) {
1211
- $author = (int)$gmCore->_get('author', $user_ID);
1212
- } else {
1213
- $author = $user_ID;
1214
- }
1215
-
1216
- $pager_html = '';
1217
- $term = array(
1218
- 'name' => '',
1219
- 'description' => '',
1220
- 'global' => $author
1221
- );
1222
-
1223
- $filter_data = array(
1224
- 'author__in' => array()
1225
- ,'author__not_in' => array()
1226
- ,'category__in' => array() // use category id. Same as 'cat', but does not accept negative values
1227
- ,'category__not_in' => array() // use category id. Exclude multiple categories
1228
- ,'album__in' => array() // use album id. Same as 'alb'
1229
- ,'album__not_in' => array() // use album id. Exclude multiple albums
1230
- ,'tag__and' => array() // use tag ids. Display posts that are tagged with all listed tags in array
1231
- ,'tag__in' => array() // use tag ids. To display posts from either tags listed in array. Same as 'tag'
1232
- ,'tag__not_in' => array() // use tag ids. Display posts that do not have any of the listed tag ids
1233
- ,'terms_relation' => '' // allows you to describe the boolean relationship between the taxonomy queries. Possible values are 'OR', 'AND'. Default 'AND'
1234
- ,'gmedia__in' => array() // use gmedia ids. Specify posts to retrieve
1235
- ,'gmedia__not_in' => array() // use gmedia ids. Specify post NOT to retrieve
1236
- ,'mime_type' => array() // mime types
1237
-
1238
- ,'limit' => '' // (int) - set limit
1239
- ,'per_page' => '' // (int) - set limit
1240
- ,'order' => '' // Designates the ascending or descending order of the 'orderby' parameter. Defaults to 'DESC'
1241
- ,'orderby' => '' // Sort retrieved posts by parameter. Defaults to 'ID'
1242
- ,'year' => '' // (int) - 4 digit year
1243
- ,'monthnum' => '' // (int) - Month number (from 1 to 12)
1244
- ,'day' => '' // (int) - Day of the month (from 1 to 31)
1245
-
1246
- ,'meta_query' => array(
1247
- array(
1248
- 'key' => '',
1249
- 'value' => '',
1250
- 'compare' => '',
1251
- 'type' => ''
1252
- )
1253
- )
1254
- ,'s' => '' // (string) - search string or terms separated by comma
1255
- ,'exact' => false // Search exactly string if 'exact' parameter set to true
1256
-
1257
- );
1258
-
1259
- $filter_variable_data = $term_query = array(
1260
- 'cache_results' => false,
1261
- 'page' => $cur_page, // number of page. Show the posts that would normally show up just on page X.
1262
- 'per_page' => $per_page // number of post to displace or pass over. Note: Setting offset parameter will ignore the 'page' parameter.
1263
- );
1264
-
1265
- $filter_form_custom_data = array(
1266
- 'gmedia_album' => array(),
1267
- 'gmedia_category' => array(),
1268
- 'gmedia_tag' => array(),
1269
- 'gmedia_id' => array(),
1270
- 'author_id' => array(),
1271
- 'album__condition' => 'album__in',
1272
- 'category__condition' => 'category__in',
1273
- 'tag__condition' => 'tag__in',
1274
- 'gmedia_id__condition' => 'gmedia__in',
1275
- 'author_id__condition' => 'author__in'
1276
- );
1277
- /**
1278
- * @var $gmedia_album
1279
- * @var $gmedia_category
1280
- * @var $gmedia_tag
1281
- * @var $gmedia_id
1282
- * @var $author_id
1283
- * @var $album__condition
1284
- * @var $category__condition
1285
- * @var $tag__condition
1286
- * @var $gmedia_id__condition
1287
- * @var $author_id__condition
1288
- */
1289
- extract($filter_form_custom_data);
1290
-
1291
- $totalResult = 0;
1292
- $trueTotalResult = 0;
1293
- if ($term_id) {
1294
- $term = $gmDB->get_term($term_id, $taxonomy, ARRAY_A);
1295
- if (! empty($term) && ! is_wp_error($term)) {
1296
-
1297
- $term_query = $gmDB->get_metadata('gmedia_term', $term['term_id'], '_query', true);
1298
- $filter_data = array_merge($filter_data, $term_query);
1299
-
1300
- $term_query = array_merge($filter_variable_data, $term_query);
1301
-
1302
- if (isset($_GET['author']) && ($term['global'] != $author)) {
1303
- $filter_data['_query']['gmedia_album'] = array();
1304
- $term['global'] = $author;
1305
- $author_new = true;
1306
- }
1307
-
1308
- if (! empty($filter_data['album__not_in'])) {
1309
- $album__condition = 'album__not_in';
1310
- }
1311
- $gmedia_album = $filter_data[$album__condition];
1312
-
1313
- if (! empty($filter_data['category__not_in'])) {
1314
- $category__condition = 'category__not_in';
1315
- }
1316
- $gmedia_category = $filter_data[$category__condition];
1317
-
1318
- if (! empty($filter_data['tag__not_in'])) {
1319
- $tag__condition = 'tag__not_in';
1320
- } elseif (! empty($filter_data['tag__and'])) {
1321
- $tag__condition = 'tag__and';
1322
- }
1323
- $gmedia_tag = $filter_data[$tag__condition];
1324
-
1325
- if (! empty($filter_data['gmedia__not_in'])) {
1326
- $gmedia_id__condition = 'gmedia__not_in';
1327
- }
1328
- $gmedia_id = $filter_data[$gmedia_id__condition];
1329
-
1330
- if (! empty($filter_data['author__not_in'])) {
1331
- $author_id__condition = 'author__not_in';
1332
- }
1333
- $author_id = $filter_data[$author_id__condition];
1334
-
1335
- $termItems = $gmDB->get_gmedias($term_query);
1336
- $totalResult = (int)$gmDB->totalResult;
1337
- if (! $totalResult && ! empty($termItems)) {
1338
- $totalResult = count($termItems);
1339
- }
1340
- if (!empty($gmDB->trueTotalResult)) {
1341
- $trueTotalResult = $gmDB->trueTotalResult;
1342
- }
1343
-
1344
- if (! empty($termItems)) {
1345
- $pager_html = $gmDB->query_pager();
1346
- }
1347
- } else {
1348
- $term_id = 0;
1349
- }
1350
- }
1351
-
1352
- ?>
1353
- <div class="panel panel-default">
1354
- <div class="panel-heading clearfix">
1355
- <div class="btn-toolbar pull-left">
1356
- <div class="btn-group" style="margin-right:20px;">
1357
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
1358
- <?php _e('Return to') ?> <span class="caret"></span>
1359
- </button>
1360
- <ul class="dropdown-menu" role="menu">
1361
- <li><a href="<?php echo add_query_arg(array('term' => 'gmedia_album'), $url); ?>"><?php _e('Albums', 'grand-media'); ?></a></li>
1362
- <li><a href="<?php echo add_query_arg(array('term' => 'gmedia_tag'), $url); ?>"><?php _e('Tags', 'grand-media'); ?></a></li>
1363
- <li><a href="<?php echo add_query_arg(array('term' => 'gmedia_category'), $url); ?>"><?php _e('Categories', 'grand-media'); ?></a></li>
1364
- <li class="divider"></li>
1365
- <li class="active"><a href="<?php echo add_query_arg(array('term' => 'gmedia_filter'), $url); ?>"><?php _e('Custom Filters', 'grand-media'); ?></a></li>
1366
- </ul>
1367
- </div>
1368
-
1369
- <?php if ($term_id) { ?>
1370
- <div class="btn-group">
1371
- <a class="btn btn-default" href="#"><?php _e('Action', 'grand-media'); ?></a>
1372
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
1373
- <span class="caret"></span>
1374
- <span class="sr-only"><?php _e('Toggle Dropdown', 'grand-media'); ?></span>
1375
- </button>
1376
- <ul class="dropdown-menu" role="menu">
1377
- <li><a href="<?php echo add_query_arg(array(
1378
- 'page' => 'GrandMedia',
1379
- 'custom_filter' => $term['term_id']
1380
- ), admin_url('admin.php')); ?>"><?php _e('Show Filter in Gmedia Library', 'grand-media'); ?></a>
1381
- </li>
1382
- </ul>
1383
- </div>
1384
- <?php } ?>
1385
- </div>
1386
-
1387
- </div>
1388
-
1389
- <form method="post" id="gmedia-edit-term" name="gmEditTerm" class="panel-body">
1390
- <h4 style="margin-top:0;">
1391
- <?php if ($term_id) { ?>
1392
- <span class="pull-right"><?php echo __('ID', 'grand-media') . ": {$term['term_id']}"; ?></span>
1393
- <?php _e('Edit Filter'); ?>: <em><?php echo esc_html($term['name']); ?></em>
1394
- <?php } else {
1395
- _e('Create Filter');
1396
- } ?>
1397
- </h4>
1398
-
1399
- <div class="row">
1400
- <div class="col-xs-6">
1401
- <div class="form-group">
1402
- <label><?php _e('Filter Name', 'grand-media'); ?></label>
1403
- <input type="text" class="form-control input-sm" name="term[name]" value="<?php echo esc_attr($term['name']); ?>" placeholder="<?php _e('Filter Name', 'grand-media'); ?>" required/>
1404
- </div>
1405
- <div class="form-group pull-right">
1406
- <?php
1407
- wp_nonce_field('GmediaGallery');
1408
- wp_nonce_field('GmediaTerms', 'term_save_wpnonce');
1409
- ?>
1410
- <input type="hidden" name="term[taxonomy]" value="gmedia_filter"/>
1411
- <input type="hidden" name="term[term_id]" value="<?php echo $term_id; ?>"/>
1412
- <button type="submit" class="btn btn-primary btn-sm" name="gmedia_filter_save"><?php _e('Save', 'grand-media'); ?></button>
1413
- </div>
1414
- <p><b><?php _e('Filter Author:', 'grand-media'); ?></b>
1415
- <?php if ($gmCore->caps['gmedia_delete_others_media']) { ?>
1416
- <a href="#gallModal" data-modal="select_author" data-action="gmedia_get_modal" class="gmedia-modal" title="<?php _e('Click to choose author for gallery', 'grand-media'); ?>"><?php echo $term['global'] ? get_the_author_meta('display_name', $term['global']) : __('(no author / shared albums)'); ?></a>
1417
- <?php if ($author_new) {
1418
- echo '<br /><span class="text-danger">' . __('Note: Author changed but not saved yet. You can see Albums list only of chosen author') . '</span>';
1419
- } ?>
1420
- <?php } else {
1421
- echo $term['global'] ? get_the_author_meta('display_name', $term['global']) : '&#8212;';
1422
- } ?>
1423
- <input type="hidden" name="term[global]" value="<?php echo $term['global']; ?>"/></p>
1424
-
1425
- </div>
1426
- <div class="col-xs-6">
1427
- <div class="form-group">
1428
- <label><?php _e('Description', 'grand-media'); ?></label>
1429
- <textarea class="form-control input-sm" style="height:77px;" rows="2" name="term[description]"><?php echo $term['description']; ?></textarea>
1430
- </div>
1431
- </div>
1432
- </div>
1433
- <hr/>
1434
- <h4 style="margin-top:0;"><?php _e('Query Parameters'); ?></h4>
1435
-
1436
- <?php if ($gmCore->caps['gmedia_terms']) { ?>
1437
- <div class="form-group">
1438
- <?php
1439
- $term_type = 'gmedia_album';
1440
- $args = array();
1441
- if ($term['global']) {
1442
- if (user_can($term['global'], 'gmedia_edit_others_media')) {
1443
- $args['global'] = '';
1444
- } else {
1445
- $args['global'] = array(0, $term['global']);
1446
- }
1447
- } else {
1448
- $args['global'] = 0;
1449
- }
1450
- $gm_terms = $gmDB->get_terms($term_type, $args);
1451
-
1452
- $terms_items = '';
1453
- if (count($gm_terms)) {
1454
- foreach ($gm_terms as $_term) {
1455
- $selected = (in_array($_term->term_id, $gmedia_album)) ? ' selected="selected"' : '';
1456
- $terms_items .= '<option value="' . $_term->term_id . '"' . $selected . '>' . esc_html($_term->name) . ('public' == $_term->status ? '' : " [{$_term->status}]") . ' &nbsp; (' . $_term->count . ')</option>' . "\n";
1457
- }
1458
- }
1459
- $setvalue = ! empty($gmedia_album) ? 'data-setvalue="' . implode(',', $gmedia_album) . '"' : '';
1460
- ?>
1461
- <label><?php _e('Choose Albums', 'grand-media'); ?> </label>
1462
-
1463
- <div class="row">
1464
- <div class="col-xs-8">
1465
- <select <?php echo $setvalue; ?> id="gmedia_album" name="filter_data[gmedia_album][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Album...', 'grand-media')); ?>">
1466
- <option value=""<?php if (empty($gmedia_album)) {
1467
- echo ' selected="selected"';
1468
- } ?>><?php _e('Any Album...', 'grand-media'); ?></option>
1469
- <?php echo $terms_items; ?>
1470
- </select>
1471
- </div>
1472
- <div class="col-xs-4">
1473
- <select name="filter_data[album__condition]" class="form-control input-sm">
1474
- <option <?php selected($album__condition, 'album__in'); ?> value="album__in"><?php _e('get albums', 'grand-media'); ?></option>
1475
- <option <?php selected($album__condition, 'album__not_in'); ?> value="album__not_in"><?php _e('exclude albums', 'grand-media'); ?></option>
1476
- </select>
1477
- </div>
1478
- </div>
1479
- <p class="help-block"><?php _e('You can choose Albums from the same author as Gallery author or Albums without author', 'grand-media'); ?></p>
1480
- </div>
1481
-
1482
- <div class="form-group">
1483
- <?php
1484
- $term_type = 'gmedia_category';
1485
- $gm_terms_all = $gmGallery->options['taxonomies'][$term_type];
1486
- $gm_terms = $gmDB->get_terms($term_type, array('fields' => 'names_count'));
1487
-
1488
- $terms_items = '';
1489
- if (count($gm_terms)) {
1490
- foreach ($gm_terms as $id => $_term) {
1491
- $selected = (in_array($id, $gmedia_category)) ? ' selected="selected"' : '';
1492
- $terms_items .= '<option value="' . $id . '"' . $selected . '>' . esc_html($gm_terms_all[$_term['name']]) . ' (' . $_term['count'] . ')</option>' . "\n";
1493
- }
1494
- }
1495
- $setvalue = ! empty($gmedia_category) ? 'data-setvalue="' . implode(',', $gmedia_category) . '"' : '';
1496
- ?>
1497
- <label><?php _e('Choose Categories', 'grand-media'); ?></label>
1498
-
1499
- <div class="row">
1500
- <div class="col-xs-8">
1501
- <select <?php echo $setvalue; ?> id="gmedia_category" name="filter_data[gmedia_category][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Category...', 'grand-media')); ?>">
1502
- <option value=""<?php echo empty($gmedia_category)? ' selected="selected"' : ''; ?>><?php _e('Any Category...', 'grand-media'); ?></option>
1503
- <?php echo $terms_items; ?>
1504
- </select>
1505
- </div>
1506
- <div class="col-xs-4">
1507
- <select name="filter_data[category__condition]" class="form-control input-sm">
1508
- <option <?php selected($category__condition, 'category__in'); ?> value="category__in"><?php _e('get categories', 'grand-media'); ?></option>
1509
- <option <?php selected($category__condition, 'category__not_in'); ?> value="category__not_in"><?php _e('exclude categories', 'grand-media'); ?></option>
1510
- </select>
1511
- </div>
1512
- </div>
1513
- </div>
1514
-
1515
- <div class="form-group">
1516
- <?php
1517
- $term_type = 'gmedia_tag';
1518
- $gm_terms = $gmDB->get_terms($term_type, array('fields' => 'names_count'));
1519
-
1520
- $terms_items = '';
1521
- if (count($gm_terms)) {
1522
- foreach ($gm_terms as $id => $_term) {
1523
- $selected = (in_array($id, $gmedia_tag)) ? ' selected="selected"' : '';
1524
- $terms_items .= '<option value="' . $id . '"' . $selected . '>' . esc_html($_term['name']) . ' (' . $_term['count'] . ')</option>' . "\n";
1525
- }
1526
- }
1527
- $setvalue = ! empty($gmedia_tag) ? 'data-setvalue="' . implode(',', $gmedia_tag) . '"' : '';
1528
- ?>
1529
- <label><?php _e('Choose Tags', 'grand-media'); ?> </label>
1530
-
1531
- <div class="row">
1532
- <div class="col-xs-8">
1533
- <select <?php echo $setvalue; ?> id="gmedia_tag" name="filter_data[gmedia_tag][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('Any Tag...', 'grand-media')); ?>">
1534
- <option value=""<?php echo empty($gmedia_tag)? ' selected="selected"' : ''; ?>><?php _e('Any Tag...', 'grand-media'); ?></option>
1535
- <?php echo $terms_items; ?>
1536
- </select>
1537
- </div>
1538
- <div class="col-xs-4">
1539
- <select name="filter_data[tag__condition]" class="form-control input-sm">
1540
- <option <?php selected($tag__condition, 'tag__in'); ?> value="tag__in"><?php _e('get items with either tags', 'grand-media'); ?></option>
1541
- <option <?php selected($tag__condition, 'tag__and'); ?> value="tag__and"><?php _e('get items that have all listed tags', 'grand-media'); ?></option>
1542
- <option <?php selected($tag__condition, 'tag__not_in'); ?> value="tag__not_in"><?php _e('exclude items that have any of the listed tags', 'grand-media'); ?></option>
1543
- </select>
1544
- </div>
1545
- </div>
1546
- </div>
1547
-
1548
- <?php } ?>
1549
- <div class="form-group">
1550
- <label><?php _e('Terms Relation', 'grand-media'); ?> </label>
1551
-
1552
- <div class="row">
1553
- <div class="col-xs-4">
1554
- <select name="gmedia_filter[terms_relation]" class="form-control input-sm">
1555
- <option <?php selected($filter_data['terms_relation'], ''); ?> value=""><?php _e('AND'); ?></option>
1556
- <option <?php selected($filter_data['terms_relation'], 'OR'); ?> value="OR"><?php _e('OR'); ?></option>
1557
- </select>
1558
- </div>
1559
- <div class="col-xs-8">
1560
- <p class="help-block"><?php _e('allows you to describe the relationship between the taxonomy queries', 'grand-media'); ?></p>
1561
- </div>
1562
- </div>
1563
- </div>
1564
- <div class="form-group">
1565
- <label><?php _e('Search', 'grand-media'); ?></label>
1566
-
1567
- <div class="row">
1568
- <div class="col-xs-8">
1569
- <input type="text" class="form-control input-sm" placeholder="<?php _e('Search string or terms separated by comma', 'grand-media'); ?>" value="<?php echo $filter_data['s']; ?>" name="gmedia_filter[s]">
1570
- </div>
1571
- <div class="col-xs-4">
1572
- <div class="checkbox"><label><input type="checkbox" name="gmedia_filter[exact]" value="yes"<?php echo $filter_data['exact']? ' checked="checked"' : ''; ?> /> <?php _e('Search exactly string', 'grand-media'); ?></label></div>
1573
- </div>
1574
- </div>
1575
- </div>
1576
- <div class="form-group">
1577
- <div class="row">
1578
- <div class="col-xs-8">
1579
- <div class="pull-right"><a id="use_lib_selected" class="label label-primary" href="#libselected"><?php _e('Use selected in Library', 'grand-media'); ?></a> </div>
1580
- <label><?php _e('Gmedia IDs <small class="text-muted">separated by comma</small>', 'grand-media'); ?> </label>
1581
- <?php $value = ! empty($gmedia_id) ? implode(',', wp_parse_id_list($gmedia_id)) : ''; ?>
1582
- <textarea id="gmedia__ids" name="filter_data[gmedia_id]" rows="1" class="form-control input-sm" style="resize:vertical;" placeholder="<?php echo esc_attr(__('Gmedia IDs...', 'grand-media')); ?>"><?php echo $value; ?></textarea>
1583
- </div>
1584
- <div class="col-xs-4">
1585
- <label>&nbsp;</label>
1586
- <select name="filter_data[gmedia_id__condition]" class="form-control input-sm">
1587
- <option <?php selected($gmedia_id__condition, 'gmedia__in'); ?> value="gmedia__in"><?php _e('get gmedia IDs', 'grand-media'); ?></option>
1588
- <option <?php selected($gmedia_id__condition, 'gmedia__not_in'); ?> value="gmedia__not_in"><?php _e('exclude gmedia IDs', 'grand-media'); ?></option>
1589
- </select>
1590
- </div>
1591
- </div>
1592
- <p class="help-block"><?php _e('You can select items you want to add here right in Gmedia Library and then return here and click button "Use selected in Library"', 'grand-media'); ?></p>
1593
- </div>
1594
- <div class="form-group">
1595
- <div class="row">
1596
- <div class="col-xs-4">
1597
- <label><?php _e('Mime Type', 'grand-media'); ?> </label>
1598
- <select name="gmedia_filter[mime_type][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('All types...', 'grand-media')); ?>">
1599
- <option value=""><?php _e('All types...', 'grand-media'); ?></option>
1600
- <option <?php echo in_array('image', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="image"><?php _e('Image', 'grand-media'); ?></option>
1601
- <option <?php echo in_array('audio', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="audio"><?php _e('Audio', 'grand-media'); ?></option>
1602
- <option <?php echo in_array('video', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="video"><?php _e('Video', 'grand-media'); ?></option>
1603
- <option <?php echo in_array('text', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="text"><?php _e('Text', 'grand-media'); ?></option>
1604
- <option <?php echo in_array('application', $filter_data['mime_type'])? 'selected="selected"' : ''; ?> value="application"><?php _e('Application', 'grand-media'); ?></option>
1605
- </select>
1606
- </div>
1607
- <div class="col-xs-4">
1608
- <label><?php _e('Authors', 'grand-media'); ?></label>
1609
- <?php if ($gmCore->caps['gmedia_show_others_media']) {
1610
- $user_ids = $gmCore->get_editable_user_ids();
1611
- if (! in_array($user_ID, $user_ids)) {
1612
- array_push($user_ids, $user_ID);
1613
- }
1614
- $filter_users = get_users(array('include' => $user_ids));
1615
- $users = '';
1616
- if (count($filter_users)) {
1617
- foreach ((array)$filter_users as $user) {
1618
- $user->ID = (int)$user->ID;
1619
- $_selected = in_array($user->ID, $author_id) ? ' selected="selected"' : '';
1620
- $users .= "<option value='$user->ID'$_selected>" . esc_html($user->display_name) . "</option>";
1621
- }
1622
- }
1623
- $setvalue = ! empty($author_id) ? 'data-setvalue="' . implode(',', $author_id) . '"' : '';
1624
- ?>
1625
- <select <?php echo $setvalue; ?> name="filter_data[author_id][]" class="gmedia-combobox form-control input-sm" multiple="multiple" placeholder="<?php echo esc_attr(__('All authors...', 'grand-media')); ?>">
1626
- <option value=""><?php _e('All authors...', 'grand-media'); ?></option>
1627
- <?php echo $users; ?>
1628
- </select>
1629
- <?php } else { ?>
1630
- <input type="text" readonly="readonly" name="filter_data[author_id][]" class="gmedia-combobox form-control input-sm" value="<?php the_author_meta('display_name', $user_ID); ?>"/>
1631
- <input type="hidden" name="filter_data[author_id__condition]" value="author__in"/>
1632
- <?php } ?>
1633
- </div>
1634
- <?php if ($gmCore->caps['gmedia_show_others_media']) { ?>
1635
- <div class="col-xs-4">
1636
- <label>&nbsp;</label>
1637
- <select name="filter_data[author_id__condition]" class="form-control input-sm">
1638
- <option <?php selected($author_id__condition, 'author__in'); ?> value="author__in"><?php _e('get authors', 'grand-media'); ?></option>
1639
- <option <?php selected($author_id__condition, 'author__not_in'); ?> value="author__not_in"><?php _e('exclude authors', 'grand-media'); ?></option>
1640
- </select>
1641
- </div>
1642
- <?php } ?>
1643
- </div>
1644
- </div>
1645
- <div class="form-group">
1646
- <div class="row">
1647
- <div class="col-xs-4">
1648
- <label><?php _e('Year', 'grand-media'); ?></label>
1649
- <input type="text" class="form-control input-sm" placeholder="<?php _e('4 digit year e.g. 2011', 'grand-media'); ?>" value="<?php echo $filter_data['year']; ?>" name="gmedia_filter[year]">
1650
- </div>
1651
- <div class="col-xs-4">
1652
- <label><?php _e('Month', 'grand-media'); ?></label>
1653
- <input type="text" class="form-control input-sm" placeholder="<?php _e('from 1 to 12', 'grand-media'); ?>" value="<?php echo $filter_data['monthnum']; ?>" name="gmedia_filter[monthnum]">
1654
- </div>
1655
- <div class="col-xs-4">
1656
- <label><?php _e('Day', 'grand-media'); ?></label>
1657
- <input type="text" class="form-control input-sm" placeholder="<?php _e('from 1 to 31', 'grand-media'); ?>" value="<?php echo $filter_data['day']; ?>" name="gmedia_filter[day]">
1658
- </div>
1659
- </div>
1660
- </div>
1661
- <div class="form-group">
1662
- <?php foreach ($filter_data['meta_query'] as $i => $q) {
1663
- if ($i) {
1664
- continue;
1665
- }
1666
- ?>
1667
- <div class="row">
1668
- <div class="col-xs-6 col-sm-3">
1669
- <label><?php _e('Custom Field Key', 'grand-media'); ?></label>
1670
- <input type="text" class="form-control input-sm" value="<?php echo $q['key']; ?>" name="gmedia_filter[meta_query][<?php echo $i; ?>][key]">
1671
- <span class="help-block"><?php _e('Display items with this field key', 'grand-media'); ?></span>
1672
- </div>
1673
- <div class="col-xs-6 col-sm-3">
1674
- <label><?php _e('Custom Field Value', 'grand-media'); ?></label>
1675
- <input type="text" class="form-control input-sm" value="<?php echo $q['value']; ?>" name="gmedia_filter[meta_query][<?php echo $i; ?>][value]">
1676
- <span class="help-block"><?php _e('Display items with this field value', 'grand-media'); ?></span>
1677
- </div>
1678
- <div class="col-xs-6 col-sm-3">
1679
- <label><?php _e('Compare Operator', 'grand-media'); ?></label>
1680
- <select class="form-control input-sm" name="gmedia_filter[meta_query][<?php echo $i; ?>][compare]">
1681
- <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
1682
- <option <?php selected($q['compare'], '='); ?> value="=">= (<?php _e('Default', 'grand-media'); ?>)</option>
1683
- <option <?php selected($q['compare'], '!='); ?> value="!=">!=</option>
1684
- <option <?php selected($q['compare'], '>'); ?> value="&gt;">&gt;</option>
1685
- <option <?php selected($q['compare'], '>='); ?> value="&gt;=">&gt;=</option>
1686
- <option <?php selected($q['compare'], '<'); ?> value="&lt;">&lt;</option>
1687
- <option <?php selected($q['compare'], '<='); ?> value="&lt;=">&lt;=</option>
1688
- <option <?php selected($q['compare'], 'LIKE'); ?> value="LIKE">LIKE</option>
1689
- <option <?php selected($q['compare'], 'NOT LIKE'); ?> value="NOT LIKE">NOT LIKE</option>
1690
- <?php /* ?>
1691
- <option <?php selected($q['compare'], 'IN'); ?> value="IN">IN</option>
1692
- <option <?php selected($q['compare'], 'NOT IN'); ?> value="NOT IN">NOT IN</option>
1693
- <option <?php selected($q['compare'], 'BETWEEN'); ?> value="BETWEEN">BETWEEN</option>
1694
- <option <?php selected($q['compare'], 'NOT BETWEEN'); ?> value="NOT BETWEEN">NOT BETWEEN</option>
1695
- <?php */ ?>
1696
- <option <?php selected($q['compare'], 'EXISTS'); ?> value="EXISTS">EXISTS</option>
1697
- </select>
1698
- <span class="help-block"><?php _e('Operator to test the field value', 'grand-media'); ?></span>
1699
- </div>
1700
- <div class="col-xs-6 col-sm-3">
1701
- <label><?php _e('Meta Type', 'grand-media'); ?></label>
1702
- <select class="form-control input-sm" name="gmedia_filter[meta_query][<?php echo $i; ?>][type]">
1703
- <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
1704
- <option <?php selected($q['type'], 'NUMERIC'); ?> value="NUMERIC">NUMERIC</option>
1705
- <option <?php selected($q['type'], 'BINARY'); ?> value="BINARY">BINARY</option>
1706
- <option <?php selected($q['type'], 'DATE'); ?> value="DATE">DATE</option>
1707
- <option <?php selected($q['type'], 'CHAR'); ?> value="CHAR">CHAR (<?php _e('Default', 'grand-media'); ?>)</option>
1708
- <option <?php selected($q['type'], 'DATETIME'); ?> value="DATETIME">DATETIME</option>
1709
- <option <?php selected($q['type'], 'DECIMAL'); ?> value="DECIMAL">DECIMAL</option>
1710
- <option <?php selected($q['type'], 'SIGNED'); ?> value="SIGNED">SIGNED</option>
1711
- <option <?php selected($q['type'], 'TIME'); ?> value="TIME">TIME</option>
1712
- <option <?php selected($q['type'], 'UNSIGNED'); ?> value="UNSIGNED">UNSIGNED</option>
1713
- </select>
1714
- <span class="help-block"><?php _e('Custom field type', 'grand-media'); ?></span>
1715
- </div>
1716
- </div>
1717
- <?php } ?>
1718
- </div>
1719
- <div class="form-group">
1720
- <div class="row">
1721
- <div class="col-xs-6 col-sm-3">
1722
- <label><?php _e('Order', 'grand-media'); ?></label>
1723
- <select class="form-control input-sm" name="gmedia_filter[order]">
1724
- <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
1725
- <option <?php selected($filter_data['order'], 'ASC'); ?> value="ASC"><?php _e('ASC', 'grand-media'); ?></option>
1726
- <option <?php selected($filter_data['order'], 'DESC'); ?> value="DESC"><?php _e('DESC - Default', 'grand-media'); ?></option>
1727
- </select>
1728
- <span class="help-block"><?php _e('Ascending or Descending order', 'grand-media'); ?></span>
1729
- </div>
1730
- <div class="col-xs-6 col-sm-3">
1731
- <label><?php _e('Order by', 'grand-media'); ?></label>
1732
- <select class="form-control input-sm" name="gmedia_filter[orderby]">
1733
- <option value=""><?php _e('Choose..', 'grand-media'); ?></option>
1734
- <option <?php selected($filter_data['orderby'], 'none'); ?> value="none"><?php _e('None', 'grand-media'); ?></option>
1735
- <option <?php selected($filter_data['orderby'], 'rand'); ?> value="rand"><?php _e('Random', 'grand-media'); ?></option>
1736
- <option <?php selected($filter_data['orderby'], 'id'); ?> value="id"><?php _e('ID', 'grand-media'); ?></option>
1737
- <option <?php selected($filter_data['orderby'], 'title'); ?> value="title"><?php _e('Title', 'grand-media'); ?></option>
1738
- <option <?php selected($filter_data['orderby'], 'gmuid'); ?> value="gmuid"><?php _e('Filename', 'grand-media'); ?></option>
1739
- <option <?php selected($filter_data['orderby'], 'date'); ?> value="date"><?php _e('Date - Default', 'grand-media'); ?></option>
1740
- <option <?php selected($filter_data['orderby'], 'modified'); ?> value="modified"><?php _e('Modified Date', 'grand-media'); ?></option>
1741
- <option <?php selected($filter_data['orderby'], 'author'); ?> value="author"><?php _e('Author', 'grand-media'); ?></option>
1742
- <option <?php selected($filter_data['orderby'], 'gmedia__in'); ?> value="gmedia__in"><?php _e('Selected Order', 'grand-media'); ?></option>
1743
- <option <?php selected($filter_data['orderby'], 'meta_value'); ?> value="meta_value"><?php _e('Custom Field Value', 'grand-media'); ?></option>
1744
- <option <?php selected($filter_data['orderby'], 'meta_value_num'); ?> value="meta_value_num"><?php _e('Custom Field Value (Numeric)', 'grand-media'); ?></option>
1745
- </select>
1746
- <span class="help-block"><?php _e('Sort retrieved posts by', 'grand-media'); ?></span>
1747
- </div>
1748
- <div class="col-xs-6 col-sm-3">
1749
- <label><?php _e('Limit', 'grand-media'); ?></label>
1750
- <input type="text" class="form-control input-sm" value="<?php echo $filter_data['limit']; ?>" name="gmedia_filter[limit]" placeholder="<?php _e('leave empty for no limit', 'grand-media'); ?>">
1751
- <span class="help-block"><?php _e('Limit number of gmedia items', 'grand-media'); ?></span>
1752
- </div>
1753
- <div class="col-xs-6 col-sm-3 text-right">
1754
- <label style="display:block;">&nbsp;</label>
1755
- <button type="submit" class="btn btn-primary btn-sm" name="gmedia_filter_save"><?php _e('Save', 'grand-media'); ?></button>
1756
- </div>
1757
- </div>
1758
- </div>
1759
- </form>
1760
- <script type="text/javascript">
1761
- jQuery(function ($) {
1762
- <?php if($gmCore->caps['gmedia_terms']){ ?>
1763
- $('.gmedia-combobox').each(function () {
1764
- var select = $(this).selectize({
1765
- create: false,
1766
- hideSelected: true,
1767
- allowEmptyOption: true
1768
- });
1769
- var val = $(this).data('setvalue');
1770
- if (val) {
1771
- val = val.toString().split(',');
1772
- select[0].selectize.setValue(val);
1773
- }
1774
- });
1775
- <?php } ?>
1776
-
1777
- $('#use_lib_selected').on('click', function () {
1778
- var field = $('#gmedia__ids');
1779
- var valData = field.val().split(',');
1780
- var storedData = getStorage('gmuser_<?php echo $user_ID; ?>_');
1781
- storedData = storedData.get('library').split(',');
1782
- valData = $.grep(valData, function (e) {
1783
- return e;
1784
- });
1785
- $.each(storedData, function (i, id) {
1786
- if (!id) {
1787
- return true;
1788
- }
1789
- if ($.inArray(id, valData) === -1) {
1790
- valData.push(id);
1791
- }
1792
- });
1793
- field.val(valData.join(', '));
1794
- });
1795
- });
1796
-
1797
- </script>
1798
- </div>
1799
-
1800
- <div class="panel panel-default" id="queryfilter">
1801
- <div class="panel-heading clearfix">
1802
- <h4 style="margin:7px 0;" class="pull-left"><?php _e('Query Filter'); ?></h4>
1803
- <?php echo $pager_html; ?>
1804
- </div>
1805
- <div class="panel-body">
1806
- <div class="termItems clearfix">
1807
- <?php if (! empty($termItems)) {
1808
- foreach ($termItems as $item) {
1809
- $item_class = '';
1810
- ?>
1811
- <div class="gm-img-thumbnail<?php echo $item_class; ?>" data-gmid="<?php echo $item->ID; ?>"><?php
1812
- ?><img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb', false); ?>" alt="<?php echo $item->ID; ?>" title="<?php echo esc_attr($item->title); ?>"/><?php
1813
- ?><span class="label label-default">ID: <?php echo $item->ID; ?></span><?php
1814
- ?><div class="gm-img-thumb-title"><?php echo esc_html($item->title); ?></div>
1815
- </div>
1816
- <?php
1817
- }
1818
- } else {
1819
- if ($term_id) { ?>
1820
- <p class="text-center"><?php _e('No items with selected parameters.') ?></p>
1821
- <?php } else { ?>
1822
- <p class="text-center"><?php _e('Set Filter parameters and click Save button to test query.') ?></p>
1823
- <?php }
1824
- } ?>
1825
- </div>
1826
- </div>
1827
- <div class="panel-footer clearfix" style="margin-top:20px;"><?php echo $pager_html; ?>
1828
- <?php if ($trueTotalResult) { ?>
1829
- <div class="well well-sm pull-left" style="margin-right:10px;"><?php printf(__('Limited to: %d'), $totalResult); ?></div>
1830
- <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $trueTotalResult); ?></div>
1831
- <?php } else { ?>
1832
- <div class="well well-sm pull-left" style="margin:0;"><?php printf(__('Total items: %d'), $totalResult); ?></div>
1833
- <?php } ?>
1834
- </div>
1835
- </div>
1836
-
1837
- <?php if ($gmCore->caps['gmedia_edit_others_media']) { ?>
1838
- <div class="modal fade gmedia-modal" id="gallModal" tabindex="-1" role="dialog" aria-hidden="true">
1839
- <div class="modal-dialog"></div>
1840
- </div>
1841
- <?php } ?>
1842
-
1843
- <?php
1844
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/comments.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Gmedia Comments
4
+ */
5
+
6
+ require_once(ABSPATH . 'wp-admin/includes/meta-boxes.php');
7
+
8
+ wp_enqueue_script('post');
9
+ wp_enqueue_script('admin-comments');
10
+
11
+ global $gmDB, $gmCore, $gmGallery, $post;
12
+
13
+ $gmedia_id = $gmCore->_get('gmedia_id');
14
+ $gmedia_term_id = $gmCore->_get('gmedia_term_id');
15
+ if($gmedia_id) {
16
+ $gmedia = $gmDB->get_gmedia($gmedia_id);
17
+ gmedia_item_more_data($gmedia);
18
+ $post_id = $gmedia->post_id;
19
+ } elseif($gmedia_term_id) {
20
+ $gmedia_term = $gmDB->get_term($gmedia_term_id);
21
+ gmedia_term_item_more_data($gmedia_term);
22
+ $post_id = $gmedia_term->post_id;
23
+ } else {
24
+ die('-1');
25
+ }
26
+
27
+ $post = get_post($post_id);
28
+ ?>
29
+ <div id="commentsdiv" style="padding:1px 0;">
30
+ <style type="text/css" scoped>
31
+ #commentsdiv {padding-top:1px;}
32
+ #commentsdiv > .thumbnail {float:left; margin:0 10px 10px;}
33
+ #commentsdiv > .thumbnail img.gmedia-thumb {max-height:72px;}
34
+ #commentsdiv > h4 {margin-left:10px;}
35
+ #commentsdiv .fixed .column-author {width:20%;}
36
+ </style>
37
+ <?php
38
+ printf( '<a target="_blank" href="%s" class="pull-right">%s</a>',
39
+ esc_url( add_query_arg( array( 'p' => $post_id ), admin_url( 'edit-comments.php' ) ) ),
40
+ __('Open in new tab'));
41
+ if($gmedia_id) { ?>
42
+ <span class="thumbnail">
43
+ <?php gmedia_item_thumbnail($gmedia); ?>
44
+ </span>
45
+ <?php } ?>
46
+ <h4><?php echo $post->post_title; ?></h4>
47
+ <?php
48
+ post_comment_meta_box($post);
49
+ wp_comment_reply();
50
+ ?>
51
+ <input id="post_ID" name="p" type="hidden" value="<?php echo $post_id; ?>"/>
52
+ </div>
53
+ <script type="text/javascript">
54
+ //<![CDATA[
55
+ jQuery(document).ready(function($) {
56
+ $("table.comments-box").css("display", "")
57
+ });
58
+ //]]>
59
+ </script>
admin/tpl/modal-share.php CHANGED
@@ -6,14 +6,34 @@
6
  <h4 class="modal-title"><?php _e('GmediaCloud Page'); ?></h4>
7
  </div>
8
  <form class="modal-body" method="post" id="shareForm">
9
- <div class="form-group">
10
- <label><?php _e('Link to page', 'grand-media'); ?></label>
11
- <input name="sharelink" type="text" class="form-control sharelink" readonly="readonly" value=""/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </div>
13
  <div class="form-group">
14
- <label><?php _e('Send this link to', 'grand-media'); ?></label>
15
  <input name="email" type="email" class="form-control sharetoemail" value="" placeholder="<?php _e('Email', 'grand-media'); ?>"/>
16
- <textarea name="message" cols="20" rows="3" class="form-control" placeholder="<?php _e('Message (optional)', 'grand-media'); ?>"></textarea>
17
  </div>
18
  <input type="hidden" name="action" value="gmedia_share_page"/>
19
  <?php wp_nonce_field('share_modal', '_sharenonce'); ?>
6
  <h4 class="modal-title"><?php _e('GmediaCloud Page'); ?></h4>
7
  </div>
8
  <form class="modal-body" method="post" id="shareForm">
9
+ <div class="form-group sharelink_post">
10
+ <label><?php _e('Link to WordPress Post', 'grand-media'); ?></label>
11
+ <div class="input-group input-group-sm">
12
+ <span class="input-group-addon">
13
+ <input type="radio" name="sharelink" value="" checked />
14
+ </span>
15
+ <input type="text" class="form-control" readonly="readonly" value="" />
16
+ <span class="input-group-btn">
17
+ <a target="_blank" class="btn btn-default" href=""><span class="glyphicon glyphicon-new-window"></span></a>
18
+ </span>
19
+ </div>
20
+ </div>
21
+ <div class="form-group sharelink_page">
22
+ <label><?php _e('Link to GmediaCloud Page', 'grand-media'); ?></label>
23
+ <div class="input-group input-group-sm">
24
+ <span class="input-group-addon">
25
+ <input type="radio" name="sharelink" value="" />
26
+ </span>
27
+ <input type="text" class="form-control" readonly="readonly" value="" />
28
+ <span class="input-group-btn">
29
+ <a target="_blank" class="btn btn-default" href=""><span class="glyphicon glyphicon-new-window"></span></a>
30
+ </span>
31
+ </div>
32
  </div>
33
  <div class="form-group">
34
+ <label><?php _e('Send link to', 'grand-media'); ?></label>
35
  <input name="email" type="email" class="form-control sharetoemail" value="" placeholder="<?php _e('Email', 'grand-media'); ?>"/>
36
+ <textarea style="margin-top:4px;" name="message" cols="20" rows="3" class="form-control" placeholder="<?php _e('Message (optional)', 'grand-media'); ?>"></textarea>
37
  </div>
38
  <input type="hidden" name="action" value="gmedia_share_page"/>
39
  <?php wp_nonce_field('share_modal', '_sharenonce'); ?>
admin/tpl/search-form.php CHANGED
@@ -2,11 +2,12 @@
2
  /**
3
  * Search form template
4
  */
 
5
  ?>
6
  <form class="form-inline gmedia-search-form" role="search">
7
  <div class="form-group">
8
  <?php foreach($_GET as $key => $value) {
9
- if(in_array($key, array('page', 'edit_mode', 'author', 'mime_type', 'tag_id', 'tag__in', 'cat', 'category__in', 'alb', 'album__in'))) {
10
  ?>
11
  <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"/>
12
  <?php
2
  /**
3
  * Search form template
4
  */
5
+ global $gmCore;
6
  ?>
7
  <form class="form-inline gmedia-search-form" role="search">
8
  <div class="form-group">
9
  <?php foreach($_GET as $key => $value) {
10
+ if(in_array($key, array('page', 'edit_mode', 'author', 'global', 'mime_type', 'tag_id', 'tag__in', 'cat', 'category__in', 'alb', 'album__in', 'term'))) {
11
  ?>
12
  <input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"/>
13
  <?php
admin/wpmedia.php CHANGED
@@ -175,7 +175,7 @@ function grandWPMedia() {
175
  $image = wp_get_attachment_image($item->ID, array(50, 50), false);
176
  if(!$image) {
177
  if(($src = wp_mime_type_icon($item->ID))) {
178
- $src_image = $gmCore->gmedia_url . '/admin/img/' . wp_basename($src);
179
  $image = '<img src="' . $src_image . '" width="50" height="50" alt="icon" title="' . esc_attr($item->post_title) . '"/>';
180
  }
181
  }
175
  $image = wp_get_attachment_image($item->ID, array(50, 50), false);
176
  if(!$image) {
177
  if(($src = wp_mime_type_icon($item->ID))) {
178
+ $src_image = $gmCore->gmedia_url . '/admin/assets/img/' . wp_basename($src);
179
  $image = '<img src="' . $src_image . '" width="50" height="50" alt="icon" title="' . esc_attr($item->post_title) . '"/>';
180
  }
181
  }
app/access.php CHANGED
@@ -3,32 +3,26 @@
3
  * Application access
4
  */
5
 
 
 
6
  // don't load directly
7
- if (! defined('ABSPATH')) {
8
  die('-1');
9
  }
10
 
11
  global $wp;
12
- $gmedia_app = isset($_GET['gmedia-app']) ? $_GET['gmedia-app'] : (isset($wp->query_vars['gmedia-app']) ? $wp->query_vars['gmedia-app'] : false);
13
- if (! $gmedia_app) {
14
  die();
15
  }
16
 
17
- global $gmCore;
18
- $out = array();
19
 
20
- if (isset($_GET['service-link'])) {
21
- $transient_key = preg_replace('/[^A-Za-z0-9]/', '', $_GET['service-link']);
22
- if (false !== ($result = get_transient($transient_key))) {
23
- //$result['mypgc_REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR']; //216.70.94.77
24
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
25
- echo json_encode($result);
26
- }
27
- die();
28
- }
29
 
30
  $gmedia_options = get_option('gmediaOptions');
31
- if (empty($gmedia_options['mobile_app'])) {
32
  $out['error'] = array('code' => 'app_inactive', 'message' => 'Service not enabled/activated for this site');
33
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
34
  echo json_encode($out);
@@ -36,16 +30,16 @@ if (empty($gmedia_options['mobile_app'])) {
36
  }
37
 
38
 
39
- if (isset($_FILES['userfile']['name'])) {
40
- $globaldata = isset($_POST['account']) ? $_POST['account'] : false;
41
- if ($globaldata) {
42
  $globaldata = stripslashes($globaldata);
43
  }
44
  } else {
45
- $globaldata = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : false;
46
  }
47
 
48
- if ($globaldata) {
49
 
50
  $json = json_decode($globaldata);
51
 
@@ -53,33 +47,37 @@ if ($globaldata) {
53
  global $gmAuth;
54
  $gmAuth = new Gmedia_JSON_API_Auth_Controller();
55
 
56
- if (isset($json->counter)) {
57
  gmedia_ios_app_counters($json->counter);
58
  }
59
 
60
- if (isset($json->cookie) && ! empty($json->cookie)) {
61
  $user_id = $gmAuth->validate_auth_cookie($json->cookie);
62
- if ($user_id) {
63
  $user = wp_set_current_user($user_id);
64
- if (isset($json->add_term)) {
65
  $out = gmedia_ios_app_processor('add_term', $json->add_term);
66
- } elseif (isset($json->delete_term)) {
67
  $out = gmedia_ios_app_processor('delete_term', $json->delete_term);
68
- } elseif (isset($json->doLibrary)) {
69
  $job = gmedia_ios_app_processor('do_library', $json->doLibrary);
70
  $out = gmedia_ios_app_processor('library', $json->library, false);
71
  $out = array_merge($out, $job);
72
- } elseif (isset($json->library)) {
73
  $out = gmedia_ios_app_processor('library', $json->library);
 
 
 
 
 
74
  }
75
 
76
-
77
  } else {
78
  $out['error'] = array('code' => 'wrongcookie', 'message' => 'Not Valid User');
79
  }
80
- } elseif (isset($json->login)) {
81
  $out = gmedia_ios_app_login($json);
82
- if (! isset($out['error'])) {
83
  $user = wp_set_current_user($out['user']['id']);
84
 
85
  $gmedia_capabilities_list = array(
@@ -96,7 +94,7 @@ if ($globaldata) {
96
  'gmedia_terms_delete'
97
  );
98
  $gmedia_capabilities = array();
99
- foreach ($gmedia_capabilities_list as $cap) {
100
  $gmedia_capabilities[$cap] = current_user_can($cap);
101
  }
102
 
@@ -106,15 +104,20 @@ if ($globaldata) {
106
  $out = $out + $data;
107
  }
108
  } else {
109
- if (isset($json->library)) {
110
  $out = gmedia_ios_app_processor('library', $json->library);
 
 
 
 
 
111
  } else {
112
  $out = gmedia_ios_app_library_data();
113
  }
114
  }
115
 
116
- } elseif ('lostpassword' == $gmCore->_get('action')) {
117
- if (function_exists('wp_lostpassword_url')) {
118
  $url = wp_lostpassword_url();
119
  } else {
120
  $url = add_query_arg('action', 'lostpassword', wp_login_url());
@@ -129,20 +132,19 @@ if ($globaldata) {
129
  *
130
  * @return array
131
  */
132
- function gmedia_ios_app_login($json)
133
- {
134
  global $gmAuth;
135
 
136
  do {
137
- if (empty($json->login)) {
138
  $out['error'] = array('code' => 'nologin', 'title' => 'No Login', 'message' => 'No Login');
139
  break;
140
  }
141
- if (! isset($json->password) || empty($json->password)) {
142
  $out['error'] = array('code' => 'nopassword', 'title' => 'No Password', 'message' => 'No Password');
143
  break;
144
  }
145
- if (! ($uid = username_exists($json->login))) {
146
  $out['error'] = array(
147
  'code' => 'nouser',
148
  'title' => 'Sorry, we can\'t log you in.',
@@ -158,7 +160,7 @@ function gmedia_ios_app_login($json)
158
  );
159
  $out = $gmAuth->generate_auth_cookie($args);
160
 
161
- } while (0);
162
 
163
  return $out;
164
  }
@@ -166,36 +168,52 @@ function gmedia_ios_app_login($json)
166
  /**
167
  * @param array $data
168
  *
 
 
169
  * @return array
170
  */
171
  function gmedia_ios_app_library_data(
172
- $data = array('site', 'authors', 'filter', 'gmedia_category', 'gmedia_album', 'gmedia_tag')
 
173
  ) {
174
- global $user_ID, $gmCore, $gmDB, $gmGallery;
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  $out = array();
177
 
178
  $ep = $gmGallery->options['endpoint'];
179
- if (get_option('permalink_structure')) {
180
  $share_link = home_url(urlencode($ep) . '/$2/$1');
181
  } else {
182
  $share_link = add_query_arg(array("$ep" => '$1', 't' => '$2'), home_url('index.php'));
183
  }
184
 
185
- if (in_array('site', $data)) {
186
  $out['site'] = array(
187
  'title' => get_bloginfo('name'),
188
  'description' => get_bloginfo('description')
189
  );
190
  }
191
- if (in_array('authors', $data)) {
192
  $out['authors'] = array(
193
  'data' => array()
194
  );
195
  //if(current_user_can('gmedia_show_others_media') || current_user_can('gmedia_edit_others_media')){
196
  $authors = get_users(array('who' => 'authors', 'orderby' => 'display_name'));
197
- if ($authors) {
198
- foreach ($authors as $author) {
199
  $out['authors']['data'][] = array(
200
  'id' => $author->ID,
201
  'displayname' => $author->display_name,
@@ -212,12 +230,12 @@ function gmedia_ios_app_library_data(
212
  $out['authors']['data'][] = array('id' => $user_ID, 'displayname' => $display_name, 'firstname' => $first_name, 'lastname' => $last_name);
213
  }*/
214
  }
215
- if (in_array('filter', $data)) {
216
  $gmDB->clauses = array();
217
  $out['filter'] = $gmDB->count_gmedia();
218
  $out['filter'] = array_map('intval', $out['filter']);
219
  }
220
- if (in_array('gmedia_category', $data)) {
221
  /*
222
  if($user_ID){
223
  $cap = (is_super_admin($user_ID) || user_can($user_ID, 'gmedia_category_delete'))? 4 : (user_can($user_ID, 'gmedia_category_edit')? 2 : 0);
@@ -225,57 +243,138 @@ function gmedia_ios_app_library_data(
225
  $cap = 0;
226
  }
227
  */
228
- $gmediaTerms = $gmDB->get_terms('gmedia_category', array('fields' => 'name=>all'));
 
 
 
 
 
 
 
 
 
 
 
 
229
  $terms = array_merge(array('0' => __('Uncategorized', 'grand-media')),
230
- $gmGallery->options['taxonomies']['gmedia_category']);
231
  $out['categories'] = array(
232
  'list' => $terms,
233
  'cap' => 0,
234
  'data' => array()
235
  );
236
- if (! empty($gmediaTerms)) {
237
- foreach ($gmediaTerms as $name => $term) {
238
- unset($gmediaTerms[$name]->description, $gmediaTerms[$name]->global, $gmediaTerms[$name]->status);
239
- $gmediaTerms[$name]->title = $terms[$name];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
 
241
- $gmedia_hashid = gmedia_hash_id_encode($gmediaTerms[$name]->term_id, 'category');
242
- $gmediaTerms[$name]->sharelink = str_replace(array('$1', '$2'), array(urlencode($gmedia_hashid), 'k'),
243
- $share_link);
244
 
245
- $gmediaTerms[$name]->cap = 0;
 
 
 
 
246
  }
247
 
248
- $out['categories']['data'] = array_values($gmediaTerms);
 
249
  }
250
  }
251
- if (in_array('gmedia_album', $data)) {
252
- $args = array();
253
- if ($user_ID) {
254
- if (current_user_can('gmedia_delete_terms')) {
 
 
 
 
 
255
  $cap = 4;
256
- } elseif (current_user_can('gmedia_album_edit')) {
257
  $cap = 2;
258
  } else {
259
  $cap = 0;
260
  }
261
  /*if( !current_user_can('gmedia_edit_others_media')){
262
- //$args = array( 'status' => array('public', 'private') );
263
- //$args['global'] = array( $user_ID, 0 );
264
  }*/
265
  } else {
266
- $cap = 0;
267
- $args = array('status' => 'public');
 
 
 
268
  }
 
 
269
  $gmediaTerms = $gmDB->get_terms('gmedia_album', $args);
270
- foreach ($gmediaTerms as $i => $term) {
 
 
 
 
 
 
 
271
  $author_id = (int)$term->global;
272
- if ($author_id) {
273
- if (($author_id != $user_ID) && ('draft' == $term->status) && ! current_user_can('gmedia_edit_others_media')) {
274
  unset($gmediaTerms[$i]);
275
  continue;
276
  }
277
  $authordata = get_userdata($author_id);
278
- if ($authordata) {
279
  $display_name = $authordata->display_name;
280
  $first_name = $authordata->first_name;
281
  $last_name = $authordata->last_name;
@@ -301,41 +400,43 @@ function gmedia_ios_app_library_data(
301
  $term_meta['orderby'] = $term_meta['_orderby'];
302
  $term_meta['order'] = $term_meta['_order'];
303
 
304
- if (! isset($term_meta['_cover'])) {
305
- $term_meta['_cover'] = '';
 
 
306
  }
307
- if ($term_meta['_cover']) {
308
- $cover_id = intval($term_meta['_cover']);
309
  $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($cover_id)), false);
310
- if (isset($cover['data'][0])) {
311
  $term_meta['_cover'] = $cover['data'][0];
312
  $gmediaTerms[$i]->thumbnail = $gmCore->gm_get_media_image($cover_id, 'thumb', false);
313
  } else {
314
- $term_meta['_cover'] = '';
315
  }
316
  }
317
- if (! $term_meta['_cover'] && $term->count) {
318
- $args = array(
319
  'no_found_rows' => true,
320
  'mime_type' => 'image/*',
321
  'per_page' => 1,
322
  'album__in' => array($term->term_id),
323
- 'status' => 'public'
324
  );
325
- if ($user_ID) {
326
- $args['status'] = array('public', 'private');
327
- if ($author_id === $user_ID) {
328
- $args['status'] = '';
329
  }
330
  } else {
331
- $args['status'] = 'public';
332
  }
333
 
334
- $termItems = $gmDB->get_gmedias($args);
335
- if (! empty($termItems)) {
336
  $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($termItems[0]->ID)),
337
- false);
338
- if (isset($cover['data'][0])) {
339
  $term_meta['_cover'] = $cover['data'][0];
340
  }
341
  $gmediaTerms[$i]->thumbnail = $gmCore->gm_get_media_image($termItems[0], 'thumb', false);
@@ -346,35 +447,58 @@ function gmedia_ios_app_library_data(
346
 
347
  $gmedia_hashid = gmedia_hash_id_encode($term->term_id, 'album');
348
  $gmediaTerms[$i]->sharelink = str_replace(array('$1', '$2'), array(urlencode($gmedia_hashid), 'a'),
349
- $share_link);
 
 
 
 
 
 
 
 
350
 
351
- $gmediaTerms[$i]->cap = (4 == $cap) ? 4 : 0;
352
  }
353
  $out['albums'] = array(
354
- 'cap' => $cap,
355
- 'data' => array_values($gmediaTerms)
 
356
  );
357
  }
358
- if (in_array('gmedia_tag', $data)) {
359
- if ($user_ID) {
360
- $cap = (is_super_admin($user_ID) || user_can($user_ID, 'gmedia_tag_delete')) ? 4 : (user_can($user_ID,
361
- 'gmedia_tag_edit') ? 2 : 0);
 
362
  } else {
363
  $cap = 0;
364
  }
365
- $gmediaTerms = $gmDB->get_terms('gmedia_tag');
366
- foreach ($gmediaTerms as $i => $term) {
 
 
 
 
 
 
 
 
 
 
 
367
  unset($gmediaTerms[$i]->description, $gmediaTerms[$i]->global, $gmediaTerms[$i]->status);
368
 
 
 
369
  $gmedia_hashid = gmedia_hash_id_encode($term->term_id, 'tag');
370
  $gmediaTerms[$i]->sharelink = str_replace(array('$1', '$2'), array(urlencode($gmedia_hashid), 't'),
371
- $share_link);
372
 
373
- $gmediaTerms[$i]->cap = (4 == $cap) ? 4 : 0;
374
  }
375
  $out['tags'] = array(
376
- 'cap' => $cap,
377
- 'data' => $gmediaTerms
 
378
  );
379
  }
380
 
@@ -389,25 +513,30 @@ function gmedia_ios_app_library_data(
389
  *
390
  * @return array
391
  */
392
- function gmedia_ios_app_processor($action, $data, $filter = true)
393
- {
394
- global $gmCore, $gmDB, $gmGallery, $user_ID;
395
 
396
  $out = array();
397
 
 
 
 
 
 
 
398
  $error = array();
399
  $alert = array();
400
  $data = (array)$data;
401
- switch ($action) {
402
  case 'do_library':
403
 
404
- if (! isset($data['action'])) {
405
  return $out;
406
  }
407
- switch ($data['action']) {
408
 
409
  case 'add_media':
410
- if (! current_user_can('gmedia_upload')) {
411
  $out['error'] = array(
412
  'code' => 'nocapability',
413
  'title' => __("You can't do this", 'grand-media'),
@@ -419,7 +548,7 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
419
 
420
  usleep(10);
421
 
422
- if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
423
  $file_name = $_FILES['userfile']['name'];
424
  $file_tmp = $_FILES['userfile']['tmp_name'];
425
  } else {
@@ -428,86 +557,86 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
428
  }
429
 
430
  $fileinfo = $gmCore->fileinfo($file_name);
431
- if (false === $fileinfo) {
432
  break;
433
  }
434
 
435
  $gmedia = (array)$data['item'];
436
- if (! current_user_can('gmedia_terms')) {
437
  unset($gmedia['categories'], $gmedia['albums'], $gmedia['tags']);
438
  } else {
439
- if (! empty($gmedia['categories'])) {
440
  $cat = $gmedia['categories'][0]->name;
441
  $gmedia['terms']['gmedia_category'] = $cat;
442
  }
443
- if (empty($gmedia['albums'])) {
444
  $gmedia['terms']['gmedia_album'] = '';
445
  } else {
446
- $alb = isset($gmedia['albums'][0]->term_id) ? $gmedia['albums'][0]->term_id : $gmedia['albums'][0]->name;
447
  $gmedia['terms']['gmedia_album'] = $alb;
448
  }
449
- if (empty($gmedia['tags'])) {
450
  $gmedia['terms']['gmedia_tag'] = '';
451
  } else {
452
  $tags = array();
453
- foreach ($gmedia['tags'] as $tag) {
454
- $tags[] = isset($tag->term_id) ? $tag->term_id : $tag->name;
455
  }
456
  $gmedia['terms']['gmedia_tag'] = implode(',', $tags);
457
  }
458
  unset($gmedia['categories'], $gmedia['albums'], $gmedia['tags']);
459
  }
460
- /*if(isset($gmedia['terms'])){
461
- $post_data = array('terms' => $gmedia['terms']);
462
- } else{
463
- $post_data = array();
464
- }*/
465
 
466
  $return = $gmCore->gmedia_upload_handler($file_tmp, $fileinfo, 'multipart', $gmedia);
467
- if (isset($return['error'])) {
468
  $error[] = $return['error']['message'];
469
  } else {
470
  $alert[] = $return['success']['message'];
471
  }
472
- break;
473
 
474
  case 'update_media':
475
  $gmedia = (array)$data['item'];
476
- if (! empty($gmedia['ID'])) {
477
  $item = $gmDB->get_gmedia($gmedia['ID']);
478
 
479
- $gmedia['modified'] = current_time('mysql');
480
- $gmedia['mime_type'] = $item->mime_type;
481
- $gmedia['gmuid'] = $item->gmuid;
482
- if (! current_user_can('gmedia_delete_others_media')) {
483
  $gmedia['author'] = $item->author;
484
  }
 
 
 
485
 
486
 
487
- if (! current_user_can('gmedia_terms')) {
488
  unset($gmedia['categories'], $gmedia['albums'], $gmedia['tags']);
489
  } else {
490
- if (! empty($gmedia['categories'])) {
491
  $cat = $gmedia['categories'][0]->name;
492
  $gmedia['terms']['gmedia_category'] = $cat;
493
  }
494
- if (empty($gmedia['albums'])) {
495
  $gmedia['terms']['gmedia_album'] = '';
496
  } else {
497
- if (isset($gmedia['albums'][0]->term_id)) {
498
  $gmedia['terms']['gmedia_album'] = $gmedia['albums'][0]->term_id;
499
- } elseif (current_user_can('gmedia_album_manage')) {
500
  $gmedia['terms']['gmedia_album'] = $gmedia['albums'][0]->name;
501
  }
502
  }
503
- if (empty($gmedia['tags'])) {
504
  $gmedia['terms']['gmedia_tag'] = '';
505
  } else {
506
  $tags = array();
507
- foreach ($gmedia['tags'] as $tag) {
508
- if (isset($tag->term_id)) {
509
  $tags[] = $tag->term_id;
510
- } elseif (current_user_can('gmedia_tag_manage')) {
511
  $tags[] = $tag->name;
512
  }
513
  }
@@ -516,178 +645,178 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
516
  unset($gmedia['categories'], $gmedia['albums'], $gmedia['tags']);
517
  }
518
 
519
- if ((int)$item->author == get_current_user_id()) {
520
- if (! current_user_can('gmedia_edit_media')) {
521
  $alert[] = __('You are not allowed to edit media', 'grand-media');
522
  }
523
  } else {
524
- if (! current_user_can('gmedia_edit_others_media')) {
525
  $alert[] = __('You are not allowed to edit others media', 'grand-media');
526
  }
527
  }
528
- if (empty($alert)) {
529
  $gmDB->insert_gmedia($gmedia);
530
  } else {
531
- if (current_user_can('gmedia_terms') && count($gmedia['terms'])) {
532
- foreach ($gmedia['terms'] as $tax => $terms) {
533
  $result = $gmDB->set_gmedia_terms($gmedia['ID'], $terms, $tax, $append = 0);
534
- if (is_wp_error($result)) {
535
  $error[] = $result->get_error_message();
536
  }
537
  }
538
  }
539
  }
540
  }
541
- break;
542
 
543
  case 'assign_category':
544
- if (! current_user_can('gmedia_terms')) {
545
  $error[] = __('You are not allowed to manage categories', 'grand-media');
546
  break;
547
  }
548
  $term = $data['assign_category'][0];
549
- if (false === $term) {
550
  break;
551
  }
552
  $count = count($data['selected']);
553
- if ('0' == $term) {
554
- foreach ($data['selected'] as $item) {
555
  $gmDB->delete_gmedia_term_relationships($item, 'gmedia_category');
556
  }
557
  $alert[] = sprintf(__('%d items updated with "Uncategorized"', 'grand-media'), $count);
558
  } else {
559
- foreach ($data['selected'] as $item) {
560
  $result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_category', $append = 0);
561
- if (is_wp_error($result)) {
562
  $error[] = $result->get_error_message();
563
  $count--;
564
- } elseif (! $result) {
565
  $count--;
566
  }
567
  }
568
- if (isset($gmGallery->options['taxonomies']['gmedia_category'][$term])) {
569
  $cat_name = $gmGallery->options['taxonomies']['gmedia_category'][$term];
570
  $alert[] = sprintf(__("Category `%s` assigned to %d images.", 'grand-media'),
571
- esc_html($cat_name), $count);
572
  } else {
573
  $error[] = sprintf(__("Category `%s` can't be assigned.", 'grand-media'), $term);
574
  }
575
  }
576
- break;
577
 
578
  case 'assign_album':
579
- if (! current_user_can('gmedia_terms')) {
580
  $error[] = __('You are not allowed to manage albums', 'grand-media');
581
  }
582
  $term = $data['assign_album'][0];
583
  $count = count($data['selected']);
584
- if ('0' == $term) {
585
- foreach ($data['selected'] as $item) {
586
  $gmDB->delete_gmedia_term_relationships($item, 'gmedia_album');
587
  }
588
  $alert[] = sprintf(__('%d items updated with "No Album"', 'grand-media'), $count);
589
  } else {
590
- foreach ($data['selected'] as $item) {
591
  $result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_album', $append = 0);
592
- if (is_wp_error($result)) {
593
  $error[] = $result->get_error_message();
594
  $count--;
595
- } elseif (! $result) {
596
  $count--;
597
  }
598
  }
599
- if ($gmCore->is_digit($term)) {
600
  $alb_name = $gmDB->get_alb_name($term);
601
  } else {
602
  $alb_name = $term;
603
  }
604
  $alert[] = sprintf(__('Album `%s` assigned to %d items', 'grand-media'), esc_html($alb_name),
605
- $count);
606
  }
607
- break;
608
 
609
  case 'add_tags':
610
- if (! current_user_can('gmedia_terms')) {
611
  $error[] = __('You are not allowed manage tags', 'grand-media');
612
  break;
613
  }
614
- if (empty($data['add_tags'])) {
615
  $error[] = __('No tags provided', 'grand-media');
616
  break;
617
  }
618
  $term = $data['add_tags'];
619
  $count = count($data['selected']);
620
- foreach ($data['selected'] as $item) {
621
  $result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_tag', $append = 1);
622
- if (is_wp_error($result)) {
623
  $error[] = $result->get_error_message();
624
  $count--;
625
- } elseif (! $result) {
626
  $count--;
627
  }
628
  }
629
  $alert[] = sprintf(__('%d tags added to %d items', 'grand-media'), count($term), $count);
630
- break;
631
 
632
  case 'delete_tags':
633
- if (! current_user_can('gmedia_delete_others_media')) {
634
  $error[] = __('You are not allowed to delete others media', 'grand-media');
635
  break;
636
  }
637
- if (empty($data['delete_tags'])) {
638
  $error[] = __('No tags provided', 'grand-media');
639
  break;
640
  }
641
  $term = array_map('intval', $data['delete_tags']);
642
  $count = count($data['selected']);
643
- foreach ($data['selected'] as $item) {
644
  $result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_tag', $append = -1);
645
- if (is_wp_error($result)) {
646
  $error[] = $result->get_error_message();
647
  $count--;
648
- } elseif (! $result) {
649
  $count--;
650
  }
651
  }
652
  $alert[] = sprintf(__('%d tags deleted from %d items', 'grand-media'), count($term), $count);
653
- break;
654
 
655
  case 'delete':
656
- if (! current_user_can('gmedia_delete_media')) {
657
  $error[] = __('You are not allowed to delete this post.');
658
  break;
659
  }
660
  $count = count($data['selected']);
661
- foreach ($data['selected'] as $item) {
662
  $gm_item = $gmDB->get_gmedia($item);
663
- if (((int)$gm_item->author != $user_ID) && ! current_user_can('gmedia_delete_others_media')) {
664
  $error[] = "#{$item}: " . __('You are not allowed to delete media others media',
665
- 'grand-media');
666
  continue;
667
  }
668
- if (! $gmDB->delete_gmedia((int)$item)) {
669
  $error[] = "#{$item}: " . __('Error in deleting...', 'grand-media');
670
  $count--;
671
  }
672
  }
673
- if ($count) {
674
  $alert[] = sprintf(__('%d items deleted successfuly', 'grand-media'), $count);
675
  }
676
- break;
677
  }
678
 
679
  $filter = gmedia_ios_app_library_data(array('filter', 'gmedia_category', 'gmedia_album', 'gmedia_tag'));
680
  $out = array_merge($out, $filter);
681
- break;
682
 
683
  case 'library':
684
  $ep = $gmGallery->options['endpoint'];
685
- if (get_option('permalink_structure')) {
686
  $share_link = home_url(urlencode($ep) . '/$2/$1');
687
  } else {
688
  $share_link = add_query_arg(array("$ep" => '$1', 't' => '$2'), home_url('index.php'));
689
  }
690
- $filter = $filter ? gmedia_ios_app_library_data(array('filter')) : array();
691
 
692
  $args = array(
693
  'mime_type' => 'image/*',
@@ -705,50 +834,50 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
705
  $data = wp_parse_args($data, $args);
706
  $false_out = array_merge($filter, array(
707
  'properties' => array(
708
- 'request' => isset($data['request']) ? $data['request'] : null
709
  ),
710
  'data' => array()
711
  ));
712
 
713
- //$is_collection = ! ( empty( $data['album__in'] ) && empty( $data['tag__in'] ) && empty( $data['category__in'] ) );
714
- $is_admin = isset($data['admin']) ? intval($data['admin']) : 0;
715
- if (! is_user_logged_in()) {
716
- $data['status'] = array('public');
717
- //if ( $is_collection ) {
718
- if (! empty($data['album__in'])) {
719
  $alb = $gmDB->get_term((int)$data['album__in'][0], 'gmedia_album');
720
- if (! (isset($alb->status) && ('public' == $alb->status))) {
721
  $out = $false_out;
722
  break;
723
  }
724
  }
725
- //} else {
726
- //$out = $false_out;
727
- //break;
728
- //}
729
  } else {
730
- if ($is_admin && ! current_user_can('gmedia_library')) {
 
731
  $out = $false_out;
732
  break;
733
  }
734
- if ($is_admin && ! current_user_can('gmedia_show_others_media')) {
735
  $data['author'] = $user_ID;
736
  }
737
  }
738
 
 
 
 
 
 
739
  $gmedias = $gmDB->get_gmedias($data);
740
- foreach ($gmedias as $i => $item) {
741
 
742
- if (! $is_admin && ('draft' == $item->status) && ((int)$user_ID != (int)$item->author)) {
743
- //if (!current_user_can('gmedia_edit_others_media')){
744
  unset($gmedias[$i]);
745
  continue;
746
- //}
747
  }
748
 
749
  $author_id = $item->author;
750
  $authordata = get_userdata($author_id);
751
- if ($authordata) {
752
  $display_name = $authordata->display_name;
753
  $first_name = $authordata->first_name;
754
  $last_name = $authordata->last_name;
@@ -766,16 +895,16 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
766
  $gmedias[$i]->date = strtotime($item->date);
767
 
768
  $meta = $gmDB->get_metadata('gmedia', $item->ID);
769
- //$_metadata = maybe_unserialize( $meta['_metadata'][0] );
770
  $_metadata = $meta['_metadata'][0];
771
  $type = explode('/', $item->mime_type);
772
  $item_url = $gmCore->upload['url'] . '/' . $gmGallery->options['folder'][$type[0]] . '/' . $item->gmuid;
773
  $gmedias[$i]->url = $item_url;
774
  $terms = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_tag');
775
  $tags = array();
776
- if ($terms) {
777
  $terms = array_values((array)$terms);
778
- foreach ($terms as $term) {
779
  $tags[] = array('term_id' => $term->term_id, 'name' => $term->name);
780
  }
781
  }
@@ -783,24 +912,24 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
783
 
784
  $terms = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_album');
785
  $albums = array();
786
- if ($terms) {
787
  $terms = array_values((array)$terms);
788
- foreach ($terms as $term) {
789
  $albums[] = array(
790
  'term_id' => $term->term_id,
791
  'name' => $term->name,
792
- 'status' => $term->status
793
  );
794
  }
795
  }
796
  $gmedias[$i]->albums = $albums;
797
 
798
- if ('image' == $type[0]) {
799
  $terms = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_category');
800
  $categories = array();
801
- if ($terms) {
802
  $terms = array_values((array)$terms);
803
- foreach ($terms as $term) {
804
  $categories[] = array('term_id' => $term->term_id, 'name' => $term->name);
805
  }
806
  }
@@ -816,13 +945,13 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
816
  $gmedias[$i]->meta['original']['link'] = "{$gmCore->upload['url']}/{$gmGallery->options['folder']['image_original']}/{$item->gmuid}";
817
  $gmedias[$i]->meta['views'] = 0;
818
  $gmedias[$i]->meta['likes'] = 0;
819
- if (isset($meta['views'][0])) {
820
  $gmedias[$i]->meta['views'] = $meta['views'][0];
821
  }
822
- if (isset($meta['likes'][0])) {
823
  $gmedias[$i]->meta['likes'] = $meta['likes'][0];
824
  }
825
- if (isset($_metadata['image_meta'])) {
826
  $gmedias[$i]->meta['data'] = $_metadata['image_meta'];
827
  }
828
  } else {
@@ -833,46 +962,49 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
833
  'height' => 300
834
  )
835
  );
836
- if (! empty($_metadata)) {
837
  $gmedias[$i]->meta['data'] = $_metadata;
838
  }
839
  }
840
- if (! empty($meta['_gps'][0])) {
841
  $gmedias[$i]->meta['data']['GPS'] = $meta['_gps'][0];
842
  }
843
- if (isset($meta['_rating'][0])) {
844
  $gmedias[$i]->meta['rating'] = maybe_unserialize($meta['_rating'][0]);
845
  }
846
 
847
- $item_name = $item->title ? $item->title : pathinfo($item->gmuid, PATHINFO_FILENAME);
848
  $gmedia_hashid = gmedia_hash_id_encode($item->ID, 'single');
849
- $gmedias[$i]->sharelink = str_replace(array('$1', '$2'), array(urlencode($gmedia_hashid), 's'),
850
- $share_link);
 
 
851
  }
852
  $out = array_merge($filter, array(
853
  'properties' => array(
854
- 'request' => isset($data['request']) ? $data['request'] : null,
855
  'total_pages' => $gmDB->pages,
856
  'current_page' => $gmDB->openPage,
857
- 'items_count' => $gmDB->gmediaCount,
858
- 'total_count' => $gmDB->totalResult
 
859
  ),
860
  'data' => array_values($gmedias)
861
  ));
862
- break;
863
  case 'delete_term':
864
  $taxonomy = $data['taxonomy'];
865
- if (! empty($data['items'])) {
866
- if (! current_user_can('gmedia_terms_delete')) {
867
  $error[] = __('You have no permission to do this operation', 'grand-media');
868
  break;
869
  }
870
  $count = count($data['items']);
871
- foreach ($data['items'] as $item) {
872
- if (! current_user_can('gmedia_edit_others_media')) {
873
- if ('gmedia_album' == $taxonomy) {
874
  $term = $gmDB->get_term($item, $taxonomy);
875
- if ((int)$term->global != (int)$user_ID) {
876
  $error['delete_album'] = __('You are not allowed to edit others media', 'grand-media');
877
  $count--;
878
  continue;
@@ -884,23 +1016,23 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
884
  }
885
  }
886
  $delete = $gmDB->delete_term($item, $taxonomy);
887
- if (is_wp_error($delete)) {
888
  $error[] = $delete->get_error_message();
889
  $count--;
890
  }
891
  }
892
- if ($count) {
893
  $alert[] = sprintf(__('%d items deleted successfuly', 'grand-media'), $count);
894
  }
895
  }
896
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy));
897
- break;
898
  case 'add_term':
899
  $taxonomy = $data['taxonomy'];
900
- $edit_term = isset($data['term_id']) ? (int)$data['term_id'] : 0;
901
  $term = $data;
902
- if ('gmedia_album' == $taxonomy) {
903
- if (! current_user_can('gmedia_album_manage')) {
904
  $out['error'] = array(
905
  'code' => 'nocapability',
906
  'title' => __("You can't do this", 'grand-media'),
@@ -911,54 +1043,57 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
911
  }
912
  do {
913
  $term['name'] = trim($term['name']);
914
- if (empty($term['name'])) {
915
  $error[] = __('Term Name is not specified', 'grand-media');
916
  break;
917
  }
918
- if ($gmCore->is_digit($term['name'])) {
919
  $error[] = __("Term Name can't be only digits", 'grand-media');
920
  break;
921
  }
922
- if ($edit_term && ! $gmDB->term_exists($edit_term, $taxonomy)) {
 
 
 
923
  $error[] = __('A term with the id provided do not exists', 'grand-media');
924
  $edit_term = false;
925
  }
926
- if (($term_id = $gmDB->term_exists($term['name'], $taxonomy))) {
927
- if ($term_id != $edit_term) {
928
  $error[] = __('A term with the name provided already exists', 'grand-media');
929
  break;
930
  }
931
  }
932
- if ($edit_term) {
933
  $_term = $gmDB->get_term($edit_term, $taxonomy);
934
- if (((int)$_term->global != (int)$user_ID) && ! current_user_can('gmedia_edit_others_media')) {
935
  $error[] = __('You are not allowed to edit others media', 'grand-media');
936
  break;
937
  }
938
  $term_id = $gmDB->update_term($edit_term, $taxonomy, $term);
939
  } else {
940
- if (! current_user_can('gmedia_edit_others_media')) {
941
  $term['global'] = intval($user_ID);
942
  }
943
  $term_id = $gmDB->insert_term($term['name'], $taxonomy, $term);
944
  }
945
- if (is_wp_error($term_id)) {
946
  $error[] = $term_id->get_error_message();
947
  break;
948
  }
949
  $term_meta = array();
950
- if (isset($term['_orderby'])) {
951
  $term_meta['_orderby'] = $term['_orderby'];
952
- } elseif (isset($term['orderby'])) {
953
  $term_meta['_orderby'] = $term['orderby'];
954
  }
955
- if (isset($term['_order'])) {
956
  $term_meta['_order'] = $term['_order'];
957
- } elseif (isset($term['order'])) {
958
  $term_meta['_order'] = $term['order'];
959
  }
960
- foreach ($term_meta as $key => $value) {
961
- if ($edit_term) {
962
  $gmDB->update_metadata('gmedia_term', $term_id, $key, $value);
963
  } else {
964
  $gmDB->add_metadata('gmedia_term', $term_id, $key, $value);
@@ -967,10 +1102,10 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
967
 
968
  $alert[] = sprintf(__('Album `%s` successfuly saved', 'grand-media'), $term['name']);
969
 
970
- } while (0);
971
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy));
972
- } elseif ('gmedia_tag' == $taxonomy) {
973
- if (! current_user_can('gmedia_tag_manage')) {
974
  $out['error'] = array(
975
  'code' => 'nocapability',
976
  'title' => __("You can't do this", 'grand-media'),
@@ -979,18 +1114,18 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
979
 
980
  return $out;
981
  }
982
- if ($edit_term) {
983
- if (! current_user_can('gmedia_edit_others_media')) {
984
  $error[] = __('You are not allowed to edit others media', 'grand-media');
985
  break;
986
  }
987
  $term['name'] = trim($term['name']);
988
  $term['term_id'] = intval($term['term_id']);
989
- if ($term['name'] && ! $gmCore->is_digit($term['name'])) {
990
- if (($term_id = $gmDB->term_exists($term['term_id'], $taxonomy))) {
991
- if (! $gmDB->term_exists($term['name'], $taxonomy)) {
992
  $term_id = $gmDB->update_term($term['term_id'], $taxonomy, $term);
993
- if (is_wp_error($term_id)) {
994
  $error[] = $term_id->get_error_message();
995
  } else {
996
  $alert[] = sprintf(__("Tag %d successfuly updated", 'grand-media'), $term_id);
@@ -1008,18 +1143,18 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
1008
  $terms = array_filter(array_map('trim', explode(',', $term['name'])));
1009
  $terms_added = 0;
1010
  $terms_qty = count($terms);
1011
- foreach ($terms as $term_name) {
1012
- if ($gmCore->is_digit($term_name)) {
1013
  continue;
1014
  }
1015
 
1016
- if (! $gmDB->term_exists($term_name, $taxonomy)) {
1017
  $term_id = $gmDB->insert_term($term_name, $taxonomy);
1018
- if (is_wp_error($term_id)) {
1019
  $error[] = $term_id->get_error_message();
1020
  } else {
1021
  $alert['tag_add'] = sprintf(__('%d of %d tags successfuly added', 'grand-media'),
1022
- ++$terms_added, $terms_qty);
1023
  }
1024
  } else {
1025
  $alert['tag_add'] = __('Some of provided tags are already exists', 'grand-media');
@@ -1029,15 +1164,15 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
1029
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy));
1030
  }
1031
 
1032
- break;
1033
  default:
1034
- break;
1035
  }
1036
 
1037
- if (! empty($error)) {
1038
  $out['error'] = array('code' => $action, 'title' => 'ERROR', 'message' => implode("\n", $error));
1039
  }
1040
- if (! empty($alert)) {
1041
  $out['alert'] = array('title' => 'Success', 'message' => implode("\n", $alert));
1042
  }
1043
 
@@ -1048,32 +1183,31 @@ function gmedia_ios_app_processor($action, $data, $filter = true)
1048
  /**
1049
  * @param $data
1050
  */
1051
- function gmedia_ios_app_counters($data)
1052
- {
1053
  global $gmDB;
1054
 
1055
  $data = (array)$data;
1056
  $items_counter = array();
1057
- if (! empty($data['views'])) {
1058
- foreach ($data['views'] as $gmID) {
1059
  $items_counter[$gmID]['views'] = 1;
1060
  }
1061
- if (! empty($data['likes'])) {
1062
- foreach ($data['likes'] as $gmID) {
1063
  $items_counter[$gmID]['likes'] = 1;
1064
  }
1065
  }
1066
  }
1067
 
1068
- if (! empty($items_counter)) {
1069
- foreach ($items_counter as $gmID => $counters) {
1070
- if (null === $gmDB->get_gmedia($gmID)) {
1071
  continue;
1072
  }
1073
  $counters['views'] = $gmDB->get_metadata('gmedia', $gmID, 'views', true);
1074
  $counters['views'] += 1;
1075
  $gmDB->update_metadata('gmedia', $gmID, 'views', $counters['views']);
1076
- if (isset($counters['likes'])) {
1077
  $counters['likes'] = $gmDB->get_metadata('gmedia', $gmID, 'likes', true);
1078
  $counters['likes'] += 1;
1079
  $gmDB->update_metadata('gmedia', $gmID, 'likes', $counters['likes']);
@@ -1084,5 +1218,9 @@ function gmedia_ios_app_counters($data)
1084
 
1085
  }
1086
 
 
 
 
 
1087
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1088
  echo json_encode($out);
3
  * Application access
4
  */
5
 
6
+ $time = - microtime(true);
7
+
8
  // don't load directly
9
+ if(!defined('ABSPATH')) {
10
  die('-1');
11
  }
12
 
13
  global $wp;
14
+ $gmedia_app = isset($_GET['gmedia-app'])? $_GET['gmedia-app'] : (isset($wp->query_vars['gmedia-app'])? $wp->query_vars['gmedia-app'] : false);
15
+ if(!$gmedia_app) {
16
  die();
17
  }
18
 
19
+ global $gmCore, $gmapp_version;
20
+ $gmapp_version = isset($_GET['gmappversion'])? $_GET['gmappversion'] : 1;
21
 
22
+ $out = array();
 
 
 
 
 
 
 
 
23
 
24
  $gmedia_options = get_option('gmediaOptions');
25
+ if(empty($gmedia_options['mobile_app'])) {
26
  $out['error'] = array('code' => 'app_inactive', 'message' => 'Service not enabled/activated for this site');
27
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
28
  echo json_encode($out);
30
  }
31
 
32
 
33
+ if(isset($_FILES['userfile']['name'])) {
34
+ $globaldata = isset($_POST['account'])? $_POST['account'] : false;
35
+ if($globaldata) {
36
  $globaldata = stripslashes($globaldata);
37
  }
38
  } else {
39
+ $globaldata = isset($GLOBALS['HTTP_RAW_POST_DATA'])? $GLOBALS['HTTP_RAW_POST_DATA'] : false;
40
  }
41
 
42
+ if($globaldata) {
43
 
44
  $json = json_decode($globaldata);
45
 
47
  global $gmAuth;
48
  $gmAuth = new Gmedia_JSON_API_Auth_Controller();
49
 
50
+ if(isset($json->counter)) {
51
  gmedia_ios_app_counters($json->counter);
52
  }
53
 
54
+ if(isset($json->cookie) && !empty($json->cookie)) {
55
  $user_id = $gmAuth->validate_auth_cookie($json->cookie);
56
+ if($user_id) {
57
  $user = wp_set_current_user($user_id);
58
+ if(isset($json->add_term)) {
59
  $out = gmedia_ios_app_processor('add_term', $json->add_term);
60
+ } elseif(isset($json->delete_term)) {
61
  $out = gmedia_ios_app_processor('delete_term', $json->delete_term);
62
+ } elseif(isset($json->doLibrary)) {
63
  $job = gmedia_ios_app_processor('do_library', $json->doLibrary);
64
  $out = gmedia_ios_app_processor('library', $json->library, false);
65
  $out = array_merge($out, $job);
66
+ } elseif(isset($json->library)) {
67
  $out = gmedia_ios_app_processor('library', $json->library);
68
+ } elseif(isset($json->library_terms)) {
69
+ $args = (array)$json->library_terms;
70
+ if(isset($args['taxonomy'])) {
71
+ $out = gmedia_ios_app_library_data(array($args['taxonomy']), $args);
72
+ }
73
  }
74
 
 
75
  } else {
76
  $out['error'] = array('code' => 'wrongcookie', 'message' => 'Not Valid User');
77
  }
78
+ } elseif(isset($json->login)) {
79
  $out = gmedia_ios_app_login($json);
80
+ if(!isset($out['error'])) {
81
  $user = wp_set_current_user($out['user']['id']);
82
 
83
  $gmedia_capabilities_list = array(
94
  'gmedia_terms_delete'
95
  );
96
  $gmedia_capabilities = array();
97
+ foreach($gmedia_capabilities_list as $cap) {
98
  $gmedia_capabilities[$cap] = current_user_can($cap);
99
  }
100
 
104
  $out = $out + $data;
105
  }
106
  } else {
107
+ if(isset($json->library)) {
108
  $out = gmedia_ios_app_processor('library', $json->library);
109
+ } elseif(isset($json->library_terms)) {
110
+ $args = (array)$json->library_terms;
111
+ if(isset($args['taxonomy'])) {
112
+ $out = gmedia_ios_app_library_data(array($args['taxonomy']), $args);
113
+ }
114
  } else {
115
  $out = gmedia_ios_app_library_data();
116
  }
117
  }
118
 
119
+ } elseif('lostpassword' == $gmCore->_get('action')) {
120
+ if(function_exists('wp_lostpassword_url')) {
121
  $url = wp_lostpassword_url();
122
  } else {
123
  $url = add_query_arg('action', 'lostpassword', wp_login_url());
132
  *
133
  * @return array
134
  */
135
+ function gmedia_ios_app_login($json) {
 
136
  global $gmAuth;
137
 
138
  do {
139
+ if(empty($json->login)) {
140
  $out['error'] = array('code' => 'nologin', 'title' => 'No Login', 'message' => 'No Login');
141
  break;
142
  }
143
+ if(!isset($json->password) || empty($json->password)) {
144
  $out['error'] = array('code' => 'nopassword', 'title' => 'No Password', 'message' => 'No Password');
145
  break;
146
  }
147
+ if(!($uid = username_exists($json->login))) {
148
  $out['error'] = array(
149
  'code' => 'nouser',
150
  'title' => 'Sorry, we can\'t log you in.',
160
  );
161
  $out = $gmAuth->generate_auth_cookie($args);
162
 
163
+ } while(0);
164
 
165
  return $out;
166
  }
168
  /**
169
  * @param array $data
170
  *
171
+ * @param $args
172
+ *
173
  * @return array
174
  */
175
  function gmedia_ios_app_library_data(
176
+ $data = array('site', 'authors', 'filter', 'gmedia_category', 'gmedia_album', 'gmedia_tag'),
177
+ $args = array()
178
  ) {
179
+ global $user_ID, $gmCore, $gmDB, $gmGallery, $gmapp_version;
180
+
181
+ if(null === $data) {
182
+ $data = array('site', 'authors', 'filter', 'gmedia_category', 'gmedia_album', 'gmedia_tag');
183
+ }
184
+
185
+ if(version_compare('3', $gmapp_version, '<=')) {
186
+ $logic = 2;
187
+ $terms_per_page = 40;
188
+ } else {
189
+ $logic = 1;
190
+ $terms_per_page = '';
191
+ }
192
+ $args = array_merge(array('number' => $terms_per_page), (array)$args);
193
 
194
  $out = array();
195
 
196
  $ep = $gmGallery->options['endpoint'];
197
+ if(get_option('permalink_structure')) {
198
  $share_link = home_url(urlencode($ep) . '/$2/$1');
199
  } else {
200
  $share_link = add_query_arg(array("$ep" => '$1', 't' => '$2'), home_url('index.php'));
201
  }
202
 
203
+ if(in_array('site', $data)) {
204
  $out['site'] = array(
205
  'title' => get_bloginfo('name'),
206
  'description' => get_bloginfo('description')
207
  );
208
  }
209
+ if(in_array('authors', $data)) {
210
  $out['authors'] = array(
211
  'data' => array()
212
  );
213
  //if(current_user_can('gmedia_show_others_media') || current_user_can('gmedia_edit_others_media')){
214
  $authors = get_users(array('who' => 'authors', 'orderby' => 'display_name'));
215
+ if($authors) {
216
+ foreach($authors as $author) {
217
  $out['authors']['data'][] = array(
218
  'id' => $author->ID,
219
  'displayname' => $author->display_name,
230
  $out['authors']['data'][] = array('id' => $user_ID, 'displayname' => $display_name, 'firstname' => $first_name, 'lastname' => $last_name);
231
  }*/
232
  }
233
+ if(in_array('filter', $data)) {
234
  $gmDB->clauses = array();
235
  $out['filter'] = $gmDB->count_gmedia();
236
  $out['filter'] = array_map('intval', $out['filter']);
237
  }
238
+ if(in_array('gmedia_category', $data)) {
239
  /*
240
  if($user_ID){
241
  $cap = (is_super_admin($user_ID) || user_can($user_ID, 'gmedia_category_delete'))? 4 : (user_can($user_ID, 'gmedia_category_edit')? 2 : 0);
243
  $cap = 0;
244
  }
245
  */
246
+ $default_args = array('fields' => 'name=>all');
247
+ if(isset($args['per_page'])) {
248
+ $args['number'] = $args['per_page'];
249
+ }
250
+ $args = array_merge($default_args, $args);
251
+ $gmediaTerms = $gmDB->get_terms('gmedia_category', $args);
252
+ $props = array(
253
+ 'per_page' => $args['number'],
254
+ 'total_pages' => $gmDB->pages,
255
+ 'current_page' => $gmDB->openPage,
256
+ 'items_count' => $gmDB->resultPerPage,
257
+ 'total_count' => $gmDB->totalResult
258
+ );
259
  $terms = array_merge(array('0' => __('Uncategorized', 'grand-media')),
260
+ $gmGallery->options['taxonomies']['gmedia_category']);
261
  $out['categories'] = array(
262
  'list' => $terms,
263
  'cap' => 0,
264
  'data' => array()
265
  );
266
+ if(!empty($gmediaTerms)) {
267
+ foreach($gmediaTerms as $i => $term) {
268
+ unset($gmediaTerms[$i]->description, $gmediaTerms[$i]->global, $gmediaTerms[$i]->status);
269
+ $gmediaTerms[$i]->title = $terms[$i];
270
+
271
+ $term_meta = $gmDB->get_metadata('gmedia_term', $term->term_id);
272
+ $term_meta = array_map('reset', $term_meta);
273
+ $term_meta = array_merge(array('_orderby' => $gmGallery->options['in_category_orderby'], '_order' => $gmGallery->options['in_category_order']), $term_meta);
274
+ $term_meta['orderby'] = $term_meta['_orderby'];
275
+ $term_meta['order'] = $term_meta['_order'];
276
+
277
+ if(empty($term_meta['_cover'])) {
278
+ $term_meta['_cover'] = false;
279
+ } else {
280
+ $term_meta['_cover'] = intval($term_meta['_cover']);
281
+ }
282
+ if($term_meta['_cover']) {
283
+ $cover_id = (int)$term_meta['_cover'];
284
+ $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($cover_id)), false);
285
+ if(isset($cover['data'][0])) {
286
+ $term_meta['_cover'] = $cover['data'][0];
287
+ $gmediaTerms[$i]->thumbnail = $gmCore->gm_get_media_image($cover_id, 'thumb', false);
288
+ } else {
289
+ $term_meta['_cover'] = false;
290
+ }
291
+ }
292
+ if(!$term_meta['_cover'] && $term->count) {
293
+ $gmargs = array(
294
+ 'no_found_rows' => true,
295
+ 'mime_type' => 'image/*',
296
+ 'per_page' => 1,
297
+ 'album__in' => array($term->term_id),
298
+ 'status' => 'publish'
299
+ );
300
+ if($user_ID) {
301
+ $gmargs['status'] = array('publish', 'private');
302
+ if(user_can($user_ID, 'gmedia_edit_others_media')) {
303
+ $gmargs['status'] = '';
304
+ }
305
+ } else {
306
+ $gmargs['status'] = 'publish';
307
+ }
308
+
309
+ $termItems = $gmDB->get_gmedias($gmargs);
310
+ if(!empty($termItems)) {
311
+ $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($termItems[0]->ID)),
312
+ false);
313
+ if(isset($cover['data'][0])) {
314
+ $term_meta['_cover'] = $cover['data'][0];
315
+ }
316
+ $gmediaTerms[$i]->thumbnail = $gmCore->gm_get_media_image($termItems[0], 'thumb', false);
317
+ }
318
+ }
319
 
320
+ $gmediaTerms[$i]->meta = $term_meta;
 
 
321
 
322
+ $gmedia_hashid = gmedia_hash_id_encode($gmediaTerms[$i]->term_id, 'category');
323
+ $gmediaTerms[$i]->sharelink = str_replace(array('$1', '$2'), array(urlencode($gmedia_hashid), 'k'),
324
+ $share_link);
325
+
326
+ $gmediaTerms[$i]->cap = 0;
327
  }
328
 
329
+ $out['categories']['properties'] = $props;
330
+ $out['categories']['data'] = array_values($gmediaTerms);
331
  }
332
  }
333
+ if(in_array('gmedia_album', $data)) {
334
+ $default_args = array();
335
+ if(2 == $logic) {
336
+ $default_args['orderby'] = 'ID';
337
+ $default_args['order'] = 'DESC';
338
+ }
339
+
340
+ if($user_ID) {
341
+ if(current_user_can('gmedia_delete_terms')) {
342
  $cap = 4;
343
+ } elseif(current_user_can('gmedia_album_edit')) {
344
  $cap = 2;
345
  } else {
346
  $cap = 0;
347
  }
348
  /*if( !current_user_can('gmedia_edit_others_media')){
349
+ //$default_args = array( 'status' => array('publish', 'private') );
350
+ //$default_args['global'] = array( $user_ID, 0 );
351
  }*/
352
  } else {
353
+ $cap = 0;
354
+ $default_args = array('status' => 'publish');
355
+ }
356
+ if(isset($args['per_page'])) {
357
+ $args['number'] = $args['per_page'];
358
  }
359
+ $args = array_merge($default_args, $args);
360
+
361
  $gmediaTerms = $gmDB->get_terms('gmedia_album', $args);
362
+ $props = array(
363
+ 'per_page' => $args['number'],
364
+ 'total_pages' => $gmDB->pages,
365
+ 'current_page' => $gmDB->openPage,
366
+ 'items_count' => $gmDB->resultPerPage,
367
+ 'total_count' => $gmDB->totalResult
368
+ );
369
+ foreach($gmediaTerms as $i => $term) {
370
  $author_id = (int)$term->global;
371
+ if($author_id) {
372
+ if(($author_id != $user_ID) && ('draft' == $term->status) && !current_user_can('gmedia_edit_others_media')) {
373
  unset($gmediaTerms[$i]);
374
  continue;
375
  }
376
  $authordata = get_userdata($author_id);
377
+ if($authordata) {
378
  $display_name = $authordata->display_name;
379
  $first_name = $authordata->first_name;
380
  $last_name = $authordata->last_name;
400
  $term_meta['orderby'] = $term_meta['_orderby'];
401
  $term_meta['order'] = $term_meta['_order'];
402
 
403
+ if(empty($term_meta['_cover'])) {
404
+ $term_meta['_cover'] = false;
405
+ } else {
406
+ $term_meta['_cover'] = intval($term_meta['_cover']);
407
  }
408
+ if($term_meta['_cover']) {
409
+ $cover_id = (int)$term_meta['_cover'];
410
  $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($cover_id)), false);
411
+ if(isset($cover['data'][0])) {
412
  $term_meta['_cover'] = $cover['data'][0];
413
  $gmediaTerms[$i]->thumbnail = $gmCore->gm_get_media_image($cover_id, 'thumb', false);
414
  } else {
415
+ $term_meta['_cover'] = false;
416
  }
417
  }
418
+ if(!$term_meta['_cover'] && $term->count) {
419
+ $gmargs = array(
420
  'no_found_rows' => true,
421
  'mime_type' => 'image/*',
422
  'per_page' => 1,
423
  'album__in' => array($term->term_id),
424
+ 'status' => 'publish'
425
  );
426
+ if($user_ID) {
427
+ $gmargs['status'] = array('publish', 'private');
428
+ if($author_id === $user_ID) {
429
+ $gmargs['status'] = '';
430
  }
431
  } else {
432
+ $gmargs['status'] = 'publish';
433
  }
434
 
435
+ $termItems = $gmDB->get_gmedias($gmargs);
436
+ if(!empty($termItems)) {
437
  $cover = gmedia_ios_app_processor('library', array('gmedia__in' => array($termItems[0]->ID)),
438
+ false);
439
+ if(isset($cover['data'][0])) {
440
  $term_meta['_cover'] = $cover['data'][0];
441
  }
442
  $gmediaTerms[$i]->thumbnail = $gmCore->gm_get_media_image($termItems[0], 'thumb', false);
447
 
448
  $gmedia_hashid = gmedia_hash_id_encode($term->term_id, 'album');
449
  $gmediaTerms[$i]->sharelink = str_replace(array('$1', '$2'), array(urlencode($gmedia_hashid), 'a'),
450
+ $share_link);
451
+
452
+ $gmediaTerms[$i]->cap = (4 == $cap)? 4 : 0;
453
+
454
+ if(1 === $logic) {
455
+ if('publish' == $gmediaTerms[$i]->status) {
456
+ $gmediaTerms[$i]->status = 'public';
457
+ }
458
+ }
459
 
 
460
  }
461
  $out['albums'] = array(
462
+ 'cap' => $cap,
463
+ 'properties' => $props,
464
+ 'data' => array_values($gmediaTerms)
465
  );
466
  }
467
+ if(in_array('gmedia_tag', $data)) {
468
+ $default_args = array();
469
+ if($user_ID) {
470
+ $cap = (is_super_admin($user_ID) || user_can($user_ID, 'gmedia_tag_delete'))? 4 : (user_can($user_ID,
471
+ 'gmedia_tag_edit')? 2 : 0);
472
  } else {
473
  $cap = 0;
474
  }
475
+ if(isset($args['per_page'])) {
476
+ $args['number'] = $args['per_page'];
477
+ }
478
+ $args = array_merge($default_args, $args);
479
+ $gmediaTerms = $gmDB->get_terms('gmedia_tag', $args);
480
+ $props = array(
481
+ 'per_page' => $args['number'],
482
+ 'total_pages' => $gmDB->pages,
483
+ 'current_page' => $gmDB->openPage,
484
+ 'items_count' => $gmDB->resultPerPage,
485
+ 'total_count' => $gmDB->totalResult
486
+ );
487
+ foreach($gmediaTerms as $i => $term) {
488
  unset($gmediaTerms[$i]->description, $gmediaTerms[$i]->global, $gmediaTerms[$i]->status);
489
 
490
+ $gmediaTerms[$i]->meta = array('_orderby' => $gmGallery->options['in_tag_orderby'], '_order' => $gmGallery->options['in_tag_order']);
491
+
492
  $gmedia_hashid = gmedia_hash_id_encode($term->term_id, 'tag');
493
  $gmediaTerms[$i]->sharelink = str_replace(array('$1', '$2'), array(urlencode($gmedia_hashid), 't'),
494
+ $share_link);
495
 
496
+ $gmediaTerms[$i]->cap = (4 == $cap)? 4 : 0;
497
  }
498
  $out['tags'] = array(
499
+ 'cap' => $cap,
500
+ 'properties' => $props,
501
+ 'data' => array_values($gmediaTerms)
502
  );
503
  }
504
 
513
  *
514
  * @return array
515
  */
516
+ function gmedia_ios_app_processor($action, $data, $filter = true) {
517
+ global $gmCore, $gmDB, $gmGallery, $user_ID, $gmapp_version;
 
518
 
519
  $out = array();
520
 
521
+ if(version_compare('3', $gmapp_version, '<=')) {
522
+ $logic = 2;
523
+ } else {
524
+ $logic = 1;
525
+ }
526
+
527
  $error = array();
528
  $alert = array();
529
  $data = (array)$data;
530
+ switch($action) {
531
  case 'do_library':
532
 
533
+ if(!isset($data['action'])) {
534
  return $out;
535
  }
536
+ switch($data['action']) {
537
 
538
  case 'add_media':
539
+ if(!current_user_can('gmedia_upload')) {
540
  $out['error'] = array(
541
  'code' => 'nocapability',
542
  'title' => __("You can't do this", 'grand-media'),
548
 
549
  usleep(10);
550
 
551
+ if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
552
  $file_name = $_FILES['userfile']['name'];
553
  $file_tmp = $_FILES['userfile']['tmp_name'];
554
  } else {
557
  }
558
 
559
  $fileinfo = $gmCore->fileinfo($file_name);
560
+ if(false === $fileinfo) {
561
  break;
562
  }
563
 
564
  $gmedia = (array)$data['item'];
565
+ if(!current_user_can('gmedia_terms')) {
566
  unset($gmedia['categories'], $gmedia['albums'], $gmedia['tags']);
567
  } else {
568
+ if(!empty($gmedia['categories'])) {
569
  $cat = $gmedia['categories'][0]->name;
570
  $gmedia['terms']['gmedia_category'] = $cat;
571
  }
572
+ if(empty($gmedia['albums'])) {
573
  $gmedia['terms']['gmedia_album'] = '';
574
  } else {
575
+ $alb = isset($gmedia['albums'][0]->term_id)? $gmedia['albums'][0]->term_id : $gmedia['albums'][0]->name;
576
  $gmedia['terms']['gmedia_album'] = $alb;
577
  }
578
+ if(empty($gmedia['tags'])) {
579
  $gmedia['terms']['gmedia_tag'] = '';
580
  } else {
581
  $tags = array();
582
+ foreach($gmedia['tags'] as $tag) {
583
+ $tags[] = isset($tag->term_id)? $tag->term_id : $tag->name;
584
  }
585
  $gmedia['terms']['gmedia_tag'] = implode(',', $tags);
586
  }
587
  unset($gmedia['categories'], $gmedia['albums'], $gmedia['tags']);
588
  }
589
+ if(isset($gmedia['status']) && 'public' == $gmedia['status']) {
590
+ $gmedia['status'] = 'publish';
591
+ }
 
 
592
 
593
  $return = $gmCore->gmedia_upload_handler($file_tmp, $fileinfo, 'multipart', $gmedia);
594
+ if(isset($return['error'])) {
595
  $error[] = $return['error']['message'];
596
  } else {
597
  $alert[] = $return['success']['message'];
598
  }
599
+ break;
600
 
601
  case 'update_media':
602
  $gmedia = (array)$data['item'];
603
+ if(!empty($gmedia['ID'])) {
604
  $item = $gmDB->get_gmedia($gmedia['ID']);
605
 
606
+ unset($gmedia['date'], $gmedia['mime_type'], $gmedia['gmuid'], $gmedia['modified']);
607
+ //$gmedia['modified'] = current_time('mysql');
608
+ if(!current_user_can('gmedia_delete_others_media')) {
 
609
  $gmedia['author'] = $item->author;
610
  }
611
+ if(isset($gmedia['status']) && 'public' == $gmedia['status']) {
612
+ $gmedia['status'] = 'publish';
613
+ }
614
 
615
 
616
+ if(!current_user_can('gmedia_terms')) {
617
  unset($gmedia['categories'], $gmedia['albums'], $gmedia['tags']);
618
  } else {
619
+ if(!empty($gmedia['categories'])) {
620
  $cat = $gmedia['categories'][0]->name;
621
  $gmedia['terms']['gmedia_category'] = $cat;
622
  }
623
+ if(empty($gmedia['albums'])) {
624
  $gmedia['terms']['gmedia_album'] = '';
625
  } else {
626
+ if(isset($gmedia['albums'][0]->term_id)) {
627
  $gmedia['terms']['gmedia_album'] = $gmedia['albums'][0]->term_id;
628
+ } elseif(current_user_can('gmedia_album_manage')) {
629
  $gmedia['terms']['gmedia_album'] = $gmedia['albums'][0]->name;
630
  }
631
  }
632
+ if(empty($gmedia['tags'])) {
633
  $gmedia['terms']['gmedia_tag'] = '';
634
  } else {
635
  $tags = array();
636
+ foreach($gmedia['tags'] as $tag) {
637
+ if(isset($tag->term_id)) {
638
  $tags[] = $tag->term_id;
639
+ } elseif(current_user_can('gmedia_tag_manage')) {
640
  $tags[] = $tag->name;
641
  }
642
  }
645
  unset($gmedia['categories'], $gmedia['albums'], $gmedia['tags']);
646
  }
647
 
648
+ if((int)$item->author == get_current_user_id()) {
649
+ if(!current_user_can('gmedia_edit_media')) {
650
  $alert[] = __('You are not allowed to edit media', 'grand-media');
651
  }
652
  } else {
653
+ if(!current_user_can('gmedia_edit_others_media')) {
654
  $alert[] = __('You are not allowed to edit others media', 'grand-media');
655
  }
656
  }
657
+ if(empty($alert)) {
658
  $gmDB->insert_gmedia($gmedia);
659
  } else {
660
+ if(current_user_can('gmedia_terms') && count($gmedia['terms'])) {
661
+ foreach($gmedia['terms'] as $tax => $terms) {
662
  $result = $gmDB->set_gmedia_terms($gmedia['ID'], $terms, $tax, $append = 0);
663
+ if(is_wp_error($result)) {
664
  $error[] = $result->get_error_message();
665
  }
666
  }
667
  }
668
  }
669
  }
670
+ break;
671
 
672
  case 'assign_category':
673
+ if(!current_user_can('gmedia_terms')) {
674
  $error[] = __('You are not allowed to manage categories', 'grand-media');
675
  break;
676
  }
677
  $term = $data['assign_category'][0];
678
+ if(false === $term) {
679
  break;
680
  }
681
  $count = count($data['selected']);
682
+ if('0' == $term) {
683
+ foreach($data['selected'] as $item) {
684
  $gmDB->delete_gmedia_term_relationships($item, 'gmedia_category');
685
  }
686
  $alert[] = sprintf(__('%d items updated with "Uncategorized"', 'grand-media'), $count);
687
  } else {
688
+ foreach($data['selected'] as $item) {
689
  $result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_category', $append = 0);
690
+ if(is_wp_error($result)) {
691
  $error[] = $result->get_error_message();
692
  $count--;
693
+ } elseif(!$result) {
694
  $count--;
695
  }
696
  }
697
+ if(isset($gmGallery->options['taxonomies']['gmedia_category'][$term])) {
698
  $cat_name = $gmGallery->options['taxonomies']['gmedia_category'][$term];
699
  $alert[] = sprintf(__("Category `%s` assigned to %d images.", 'grand-media'),
700
+ esc_html($cat_name), $count);
701
  } else {
702
  $error[] = sprintf(__("Category `%s` can't be assigned.", 'grand-media'), $term);
703
  }
704
  }
705
+ break;
706
 
707
  case 'assign_album':
708
+ if(!current_user_can('gmedia_terms')) {
709
  $error[] = __('You are not allowed to manage albums', 'grand-media');
710
  }
711
  $term = $data['assign_album'][0];
712
  $count = count($data['selected']);
713
+ if('0' == $term) {
714
+ foreach($data['selected'] as $item) {
715
  $gmDB->delete_gmedia_term_relationships($item, 'gmedia_album');
716
  }
717
  $alert[] = sprintf(__('%d items updated with "No Album"', 'grand-media'), $count);
718
  } else {
719
+ foreach($data['selected'] as $item) {
720
  $result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_album', $append = 0);
721
+ if(is_wp_error($result)) {
722
  $error[] = $result->get_error_message();
723
  $count--;
724
+ } elseif(!$result) {
725
  $count--;
726
  }
727
  }
728
+ if($gmCore->is_digit($term)) {
729
  $alb_name = $gmDB->get_alb_name($term);
730
  } else {
731
  $alb_name = $term;
732
  }
733
  $alert[] = sprintf(__('Album `%s` assigned to %d items', 'grand-media'), esc_html($alb_name),
734
+ $count);
735
  }
736
+ break;
737
 
738
  case 'add_tags':
739
+ if(!current_user_can('gmedia_terms')) {
740
  $error[] = __('You are not allowed manage tags', 'grand-media');
741
  break;
742
  }
743
+ if(empty($data['add_tags'])) {
744
  $error[] = __('No tags provided', 'grand-media');
745
  break;
746
  }
747
  $term = $data['add_tags'];
748
  $count = count($data['selected']);
749
+ foreach($data['selected'] as $item) {
750
  $result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_tag', $append = 1);
751
+ if(is_wp_error($result)) {
752
  $error[] = $result->get_error_message();
753
  $count--;
754
+ } elseif(!$result) {
755
  $count--;
756
  }
757
  }
758
  $alert[] = sprintf(__('%d tags added to %d items', 'grand-media'), count($term), $count);
759
+ break;
760
 
761
  case 'delete_tags':
762
+ if(!current_user_can('gmedia_delete_others_media')) {
763
  $error[] = __('You are not allowed to delete others media', 'grand-media');
764
  break;
765
  }
766
+ if(empty($data['delete_tags'])) {
767
  $error[] = __('No tags provided', 'grand-media');
768
  break;
769
  }
770
  $term = array_map('intval', $data['delete_tags']);
771
  $count = count($data['selected']);
772
+ foreach($data['selected'] as $item) {
773
  $result = $gmDB->set_gmedia_terms($item, $term, 'gmedia_tag', $append = -1);
774
+ if(is_wp_error($result)) {
775
  $error[] = $result->get_error_message();
776
  $count--;
777
+ } elseif(!$result) {
778
  $count--;
779
  }
780
  }
781
  $alert[] = sprintf(__('%d tags deleted from %d items', 'grand-media'), count($term), $count);
782
+ break;
783
 
784
  case 'delete':
785
+ if(!current_user_can('gmedia_delete_media')) {
786
  $error[] = __('You are not allowed to delete this post.');
787
  break;
788
  }
789
  $count = count($data['selected']);
790
+ foreach($data['selected'] as $item) {
791
  $gm_item = $gmDB->get_gmedia($item);
792
+ if(((int)$gm_item->author != $user_ID) && !current_user_can('gmedia_delete_others_media')) {
793
  $error[] = "#{$item}: " . __('You are not allowed to delete media others media',
794
+ 'grand-media');
795
  continue;
796
  }
797
+ if(!$gmDB->delete_gmedia((int)$item)) {
798
  $error[] = "#{$item}: " . __('Error in deleting...', 'grand-media');
799
  $count--;
800
  }
801
  }
802
+ if($count) {
803
  $alert[] = sprintf(__('%d items deleted successfuly', 'grand-media'), $count);
804
  }
805
+ break;
806
  }
807
 
808
  $filter = gmedia_ios_app_library_data(array('filter', 'gmedia_category', 'gmedia_album', 'gmedia_tag'));
809
  $out = array_merge($out, $filter);
810
+ break;
811
 
812
  case 'library':
813
  $ep = $gmGallery->options['endpoint'];
814
+ if(get_option('permalink_structure')) {
815
  $share_link = home_url(urlencode($ep) . '/$2/$1');
816
  } else {
817
  $share_link = add_query_arg(array("$ep" => '$1', 't' => '$2'), home_url('index.php'));
818
  }
819
+ $filter = $filter? gmedia_ios_app_library_data(array('filter')) : array();
820
 
821
  $args = array(
822
  'mime_type' => 'image/*',
834
  $data = wp_parse_args($data, $args);
835
  $false_out = array_merge($filter, array(
836
  'properties' => array(
837
+ 'request' => isset($data['request'])? $data['request'] : null
838
  ),
839
  'data' => array()
840
  ));
841
 
842
+ $is_admin = isset($data['admin'])? intval($data['admin']) : 0;
843
+ if(!is_user_logged_in()) {
844
+ $logged_in = false;
845
+ $data['status'] = array('publish');
846
+ if(!empty($data['album__in'])) {
 
847
  $alb = $gmDB->get_term((int)$data['album__in'][0], 'gmedia_album');
848
+ if(!(isset($alb->status) && ('publish' == $alb->status))) {
849
  $out = $false_out;
850
  break;
851
  }
852
  }
 
 
 
 
853
  } else {
854
+ $logged_in = true;
855
+ if($is_admin && !current_user_can('gmedia_library')) {
856
  $out = $false_out;
857
  break;
858
  }
859
+ if($is_admin && !current_user_can('gmedia_show_others_media')) {
860
  $data['author'] = $user_ID;
861
  }
862
  }
863
 
864
+ $_data = $data;
865
+ $_data['per_page'] = -1;
866
+ $_data['status'] = null;
867
+ $_data['fields'] = 'ids';
868
+ $all_gmedias_ids = $gmDB->get_gmedias($_data);
869
  $gmedias = $gmDB->get_gmedias($data);
870
+ foreach($gmedias as $i => $item) {
871
 
872
+ //if((!$logged_in && 'publish' != $item->status) || (!$is_admin && ('draft' == $item->status) && ((int)$user_ID != (int)$item->author))) {
873
+ if(!$is_admin && ('draft' == $item->status) && ((int)$user_ID != (int)$item->author)) {
874
  unset($gmedias[$i]);
875
  continue;
 
876
  }
877
 
878
  $author_id = $item->author;
879
  $authordata = get_userdata($author_id);
880
+ if($authordata) {
881
  $display_name = $authordata->display_name;
882
  $first_name = $authordata->first_name;
883
  $last_name = $authordata->last_name;
895
  $gmedias[$i]->date = strtotime($item->date);
896
 
897
  $meta = $gmDB->get_metadata('gmedia', $item->ID);
898
+ //$_metadata = maybe_unserialize( $meta['_metadata'][0] );
899
  $_metadata = $meta['_metadata'][0];
900
  $type = explode('/', $item->mime_type);
901
  $item_url = $gmCore->upload['url'] . '/' . $gmGallery->options['folder'][$type[0]] . '/' . $item->gmuid;
902
  $gmedias[$i]->url = $item_url;
903
  $terms = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_tag');
904
  $tags = array();
905
+ if($terms) {
906
  $terms = array_values((array)$terms);
907
+ foreach($terms as $term) {
908
  $tags[] = array('term_id' => $term->term_id, 'name' => $term->name);
909
  }
910
  }
912
 
913
  $terms = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_album');
914
  $albums = array();
915
+ if($terms) {
916
  $terms = array_values((array)$terms);
917
+ foreach($terms as $term) {
918
  $albums[] = array(
919
  'term_id' => $term->term_id,
920
  'name' => $term->name,
921
+ 'status' => (1 === $logic && 'publish' == $term->status)? 'public' : $term->status
922
  );
923
  }
924
  }
925
  $gmedias[$i]->albums = $albums;
926
 
927
+ if('image' == $type[0]) {
928
  $terms = $gmDB->get_the_gmedia_terms($item->ID, 'gmedia_category');
929
  $categories = array();
930
+ if($terms) {
931
  $terms = array_values((array)$terms);
932
+ foreach($terms as $term) {
933
  $categories[] = array('term_id' => $term->term_id, 'name' => $term->name);
934
  }
935
  }
945
  $gmedias[$i]->meta['original']['link'] = "{$gmCore->upload['url']}/{$gmGallery->options['folder']['image_original']}/{$item->gmuid}";
946
  $gmedias[$i]->meta['views'] = 0;
947
  $gmedias[$i]->meta['likes'] = 0;
948
+ if(isset($meta['views'][0])) {
949
  $gmedias[$i]->meta['views'] = $meta['views'][0];
950
  }
951
+ if(isset($meta['likes'][0])) {
952
  $gmedias[$i]->meta['likes'] = $meta['likes'][0];
953
  }
954
+ if(isset($_metadata['image_meta'])) {
955
  $gmedias[$i]->meta['data'] = $_metadata['image_meta'];
956
  }
957
  } else {
962
  'height' => 300
963
  )
964
  );
965
+ if(!empty($_metadata)) {
966
  $gmedias[$i]->meta['data'] = $_metadata;
967
  }
968
  }
969
+ if(!empty($meta['_gps'][0])) {
970
  $gmedias[$i]->meta['data']['GPS'] = $meta['_gps'][0];
971
  }
972
+ if(isset($meta['_rating'][0])) {
973
  $gmedias[$i]->meta['rating'] = maybe_unserialize($meta['_rating'][0]);
974
  }
975
 
976
+ $item_name = $item->title? $item->title : pathinfo($item->gmuid, PATHINFO_FILENAME);
977
  $gmedia_hashid = gmedia_hash_id_encode($item->ID, 'single');
978
+ $gmedias[$i]->sharelink = str_replace(array('$1', '$2'), array(urlencode($gmedia_hashid), 's'), $share_link);
979
+ if(1 === $logic && 'publish' == $item->status) {
980
+ $gmedias[$i]->status = 'public';
981
+ }
982
  }
983
  $out = array_merge($filter, array(
984
  'properties' => array(
985
+ 'request' => isset($data['request'])? $data['request'] : null,
986
  'total_pages' => $gmDB->pages,
987
  'current_page' => $gmDB->openPage,
988
+ 'items_count' => $gmDB->resultPerPage,
989
+ 'total_count' => $gmDB->totalResult,
990
+ 'count' => count($all_gmedias_ids)
991
  ),
992
  'data' => array_values($gmedias)
993
  ));
994
+ break;
995
  case 'delete_term':
996
  $taxonomy = $data['taxonomy'];
997
+ if(!empty($data['items'])) {
998
+ if(!current_user_can('gmedia_terms_delete')) {
999
  $error[] = __('You have no permission to do this operation', 'grand-media');
1000
  break;
1001
  }
1002
  $count = count($data['items']);
1003
+ foreach($data['items'] as $item) {
1004
+ if(!current_user_can('gmedia_edit_others_media')) {
1005
+ if('gmedia_album' == $taxonomy) {
1006
  $term = $gmDB->get_term($item, $taxonomy);
1007
+ if((int)$term->global != (int)$user_ID) {
1008
  $error['delete_album'] = __('You are not allowed to edit others media', 'grand-media');
1009
  $count--;
1010
  continue;
1016
  }
1017
  }
1018
  $delete = $gmDB->delete_term($item, $taxonomy);
1019
+ if(is_wp_error($delete)) {
1020
  $error[] = $delete->get_error_message();
1021
  $count--;
1022
  }
1023
  }
1024
+ if($count) {
1025
  $alert[] = sprintf(__('%d items deleted successfuly', 'grand-media'), $count);
1026
  }
1027
  }
1028
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy));
1029
+ break;
1030
  case 'add_term':
1031
  $taxonomy = $data['taxonomy'];
1032
+ $edit_term = isset($data['term_id'])? (int)$data['term_id'] : 0;
1033
  $term = $data;
1034
+ if('gmedia_album' == $taxonomy) {
1035
+ if(!current_user_can('gmedia_album_manage')) {
1036
  $out['error'] = array(
1037
  'code' => 'nocapability',
1038
  'title' => __("You can't do this", 'grand-media'),
1043
  }
1044
  do {
1045
  $term['name'] = trim($term['name']);
1046
+ if(empty($term['name'])) {
1047
  $error[] = __('Term Name is not specified', 'grand-media');
1048
  break;
1049
  }
1050
+ if($gmCore->is_digit($term['name'])) {
1051
  $error[] = __("Term Name can't be only digits", 'grand-media');
1052
  break;
1053
  }
1054
+ if(1 === $logic && isset($term['status']) && 'public' == $term['status']) {
1055
+ $term['status'] = 'publish';
1056
+ }
1057
+ if($edit_term && !$gmDB->term_exists($edit_term, $taxonomy)) {
1058
  $error[] = __('A term with the id provided do not exists', 'grand-media');
1059
  $edit_term = false;
1060
  }
1061
+ if(($term_id = $gmDB->term_exists($term['name'], $taxonomy))) {
1062
+ if($term_id != $edit_term) {
1063
  $error[] = __('A term with the name provided already exists', 'grand-media');
1064
  break;
1065
  }
1066
  }
1067
+ if($edit_term) {
1068
  $_term = $gmDB->get_term($edit_term, $taxonomy);
1069
+ if(((int)$_term->global != (int)$user_ID) && !current_user_can('gmedia_edit_others_media')) {
1070
  $error[] = __('You are not allowed to edit others media', 'grand-media');
1071
  break;
1072
  }
1073
  $term_id = $gmDB->update_term($edit_term, $taxonomy, $term);
1074
  } else {
1075
+ if(!current_user_can('gmedia_edit_others_media')) {
1076
  $term['global'] = intval($user_ID);
1077
  }
1078
  $term_id = $gmDB->insert_term($term['name'], $taxonomy, $term);
1079
  }
1080
+ if(is_wp_error($term_id)) {
1081
  $error[] = $term_id->get_error_message();
1082
  break;
1083
  }
1084
  $term_meta = array();
1085
+ if(isset($term['_orderby'])) {
1086
  $term_meta['_orderby'] = $term['_orderby'];
1087
+ } elseif(isset($term['orderby'])) {
1088
  $term_meta['_orderby'] = $term['orderby'];
1089
  }
1090
+ if(isset($term['_order'])) {
1091
  $term_meta['_order'] = $term['_order'];
1092
+ } elseif(isset($term['order'])) {
1093
  $term_meta['_order'] = $term['order'];
1094
  }
1095
+ foreach($term_meta as $key => $value) {
1096
+ if($edit_term) {
1097
  $gmDB->update_metadata('gmedia_term', $term_id, $key, $value);
1098
  } else {
1099
  $gmDB->add_metadata('gmedia_term', $term_id, $key, $value);
1102
 
1103
  $alert[] = sprintf(__('Album `%s` successfuly saved', 'grand-media'), $term['name']);
1104
 
1105
+ } while(0);
1106
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy));
1107
+ } elseif('gmedia_tag' == $taxonomy) {
1108
+ if(!current_user_can('gmedia_tag_manage')) {
1109
  $out['error'] = array(
1110
  'code' => 'nocapability',
1111
  'title' => __("You can't do this", 'grand-media'),
1114
 
1115
  return $out;
1116
  }
1117
+ if($edit_term) {
1118
+ if(!current_user_can('gmedia_edit_others_media')) {
1119
  $error[] = __('You are not allowed to edit others media', 'grand-media');
1120
  break;
1121
  }
1122
  $term['name'] = trim($term['name']);
1123
  $term['term_id'] = intval($term['term_id']);
1124
+ if($term['name'] && !$gmCore->is_digit($term['name'])) {
1125
+ if(($term_id = $gmDB->term_exists($term['term_id'], $taxonomy))) {
1126
+ if(!$gmDB->term_exists($term['name'], $taxonomy)) {
1127
  $term_id = $gmDB->update_term($term['term_id'], $taxonomy, $term);
1128
+ if(is_wp_error($term_id)) {
1129
  $error[] = $term_id->get_error_message();
1130
  } else {
1131
  $alert[] = sprintf(__("Tag %d successfuly updated", 'grand-media'), $term_id);
1143
  $terms = array_filter(array_map('trim', explode(',', $term['name'])));
1144
  $terms_added = 0;
1145
  $terms_qty = count($terms);
1146
+ foreach($terms as $term_name) {
1147
+ if($gmCore->is_digit($term_name)) {
1148
  continue;
1149
  }
1150
 
1151
+ if(!$gmDB->term_exists($term_name, $taxonomy)) {
1152
  $term_id = $gmDB->insert_term($term_name, $taxonomy);
1153
+ if(is_wp_error($term_id)) {
1154
  $error[] = $term_id->get_error_message();
1155
  } else {
1156
  $alert['tag_add'] = sprintf(__('%d of %d tags successfuly added', 'grand-media'),
1157
+ ++$terms_added, $terms_qty);
1158
  }
1159
  } else {
1160
  $alert['tag_add'] = __('Some of provided tags are already exists', 'grand-media');
1164
  $out = gmedia_ios_app_library_data(array('filter', $taxonomy));
1165
  }
1166
 
1167
+ break;
1168
  default:
1169
+ break;
1170
  }
1171
 
1172
+ if(!empty($error)) {
1173
  $out['error'] = array('code' => $action, 'title' => 'ERROR', 'message' => implode("\n", $error));
1174
  }
1175
+ if(!empty($alert)) {
1176
  $out['alert'] = array('title' => 'Success', 'message' => implode("\n", $alert));
1177
  }
1178
 
1183
  /**
1184
  * @param $data
1185
  */
1186
+ function gmedia_ios_app_counters($data) {
 
1187
  global $gmDB;
1188
 
1189
  $data = (array)$data;
1190
  $items_counter = array();
1191
+ if(!empty($data['views'])) {
1192
+ foreach($data['views'] as $gmID) {
1193
  $items_counter[$gmID]['views'] = 1;
1194
  }
1195
+ if(!empty($data['likes'])) {
1196
+ foreach($data['likes'] as $gmID) {
1197
  $items_counter[$gmID]['likes'] = 1;
1198
  }
1199
  }
1200
  }
1201
 
1202
+ if(!empty($items_counter)) {
1203
+ foreach($items_counter as $gmID => $counters) {
1204
+ if(null === $gmDB->get_gmedia($gmID)) {
1205
  continue;
1206
  }
1207
  $counters['views'] = $gmDB->get_metadata('gmedia', $gmID, 'views', true);
1208
  $counters['views'] += 1;
1209
  $gmDB->update_metadata('gmedia', $gmID, 'views', $counters['views']);
1210
+ if(isset($counters['likes'])) {
1211
  $counters['likes'] = $gmDB->get_metadata('gmedia', $gmID, 'likes', true);
1212
  $counters['likes'] += 1;
1213
  $gmDB->update_metadata('gmedia', $gmID, 'likes', $counters['likes']);
1218
 
1219
  }
1220
 
1221
+ $time += microtime(true);
1222
+ //$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
1223
+ $out['microtime'] = $time;
1224
+
1225
  header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
1226
  echo json_encode($out);
assets/fancybox/images/blank.gif CHANGED
File without changes
assets/fancybox/images/fancy_shadow_e.png CHANGED
File without changes
assets/fancybox/images/fancy_shadow_ne.png CHANGED
File without changes
assets/fancybox/images/fancy_shadow_nw.png CHANGED
File without changes
assets/fancybox/images/fancy_shadow_se.png CHANGED
File without changes
assets/fancybox/images/fancy_shadow_sw.png CHANGED
File without changes
assets/fancybox/images/fancy_title_left.png CHANGED
File without changes
assets/fancybox/images/fancy_title_main.png CHANGED
File without changes
assets/fancybox/images/fancy_title_right.png CHANGED
File without changes
assets/fancybox/images/fancybox-x.png CHANGED
File without changes
assets/fancybox/images/fancybox.png CHANGED
File without changes
assets/fancybox/jquery.fancybox-1.3.4.css CHANGED
File without changes
assets/fancybox/jquery.fancybox-1.3.4.pack.js CHANGED
File without changes
assets/gmedia.global.front.js CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
  * gmedia Globals
3
- * @var gmediaGlobalVar
4
  */
5
- var ajaxurl = gmediaGlobalVar.ajaxurl;
1
  /**
2
  * gmedia Globals
3
+ * @var GmediaGallery
4
  */
5
+ var ajaxurl = GmediaGallery.ajaxurl;
assets/icons/favicon.png CHANGED
File without changes
assets/image-editor/image-editor.js CHANGED
File without changes
assets/image-editor/img/loader.gif CHANGED
File without changes
assets/image-editor/img/minus_plus.png CHANGED
File without changes
assets/image-editor/img/slider_bg.png CHANGED
File without changes
assets/image-editor/style.css CHANGED
File without changes
assets/jq-plugins/jquery.easing.js CHANGED
File without changes
assets/jq-plugins/jquery.tool.tabs.min.js CHANGED
File without changes
assets/jq-plugins/outside-events.js CHANGED
File without changes
assets/jqueryFileTree/images/directory.png CHANGED
File without changes
assets/jqueryFileTree/images/folder_open.png CHANGED
File without changes
assets/jqueryFileTree/images/spinner.gif CHANGED
File without changes
assets/jqueryFileTree/jqueryFileTree.css CHANGED
File without changes
assets/jqueryFileTree/jqueryFileTree.js CHANGED
File without changes
assets/mag-popup/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 Dmitry Semenov, http://dimsemenov.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
assets/mag-popup/jquery.magnific-popup.min.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /*! Magnific Popup - v1.0.1 - 2015-12-30
2
+ * http://dimsemenov.com/plugins/magnific-popup/
3
+ * Copyright (c) 2015 Dmitry Semenov; */
4
+ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(a){var b,c,d,e,f,g,h="Close",i="BeforeClose",j="AfterClose",k="BeforeAppend",l="MarkupParse",m="Open",n="Change",o="mfp",p="."+o,q="mfp-ready",r="mfp-removing",s="mfp-prevent-close",t=function(){},u=!!window.jQuery,v=a(window),w=function(a,c){b.ev.on(o+a+p,c)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(c,d){b.ev.triggerHandler(o+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},z=function(c){return c===g&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),g=c),b.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(b=new t,b.init(),a.magnificPopup.instance=b)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(void 0!==a.transition)return!0;for(;b.length;)if(b.pop()+"Transition"in a)return!0;return!1};t.prototype={constructor:t,init:function(){var c=navigator.appVersion;b.isIE7=-1!==c.indexOf("MSIE 7."),b.isIE8=-1!==c.indexOf("MSIE 8."),b.isLowIE=b.isIE7||b.isIE8,b.isAndroid=/android/gi.test(c),b.isIOS=/iphone|ipad|ipod/gi.test(c),b.supportsTransition=B(),b.probablyMobile=b.isAndroid||b.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),d=a(document),b.popupsCache={}},open:function(c){var e;if(c.isObj===!1){b.items=c.items.toArray(),b.index=0;var g,h=c.items;for(e=0;e<h.length;e++)if(g=h[e],g.parsed&&(g=g.el[0]),g===c.el[0]){b.index=e;break}}else b.items=a.isArray(c.items)?c.items:[c.items],b.index=c.index||0;if(b.isOpen)return void b.updateItemHTML();b.types=[],f="",c.mainEl&&c.mainEl.length?b.ev=c.mainEl.eq(0):b.ev=d,c.key?(b.popupsCache[c.key]||(b.popupsCache[c.key]={}),b.currTemplate=b.popupsCache[c.key]):b.currTemplate={},b.st=a.extend(!0,{},a.magnificPopup.defaults,c),b.fixedContentPos="auto"===b.st.fixedContentPos?!b.probablyMobile:b.st.fixedContentPos,b.st.modal&&(b.st.closeOnContentClick=!1,b.st.closeOnBgClick=!1,b.st.showCloseBtn=!1,b.st.enableEscapeKey=!1),b.bgOverlay||(b.bgOverlay=x("bg").on("click"+p,function(){b.close()}),b.wrap=x("wrap").attr("tabindex",-1).on("click"+p,function(a){b._checkIfClose(a.target)&&b.close()}),b.container=x("container",b.wrap)),b.contentContainer=x("content"),b.st.preloader&&(b.preloader=x("preloader",b.container,b.st.tLoading));var i=a.magnificPopup.modules;for(e=0;e<i.length;e++){var j=i[e];j=j.charAt(0).toUpperCase()+j.slice(1),b["init"+j].call(b)}y("BeforeOpen"),b.st.showCloseBtn&&(b.st.closeBtnInside?(w(l,function(a,b,c,d){c.close_replaceWith=z(d.type)}),f+=" mfp-close-btn-in"):b.wrap.append(z())),b.st.alignTop&&(f+=" mfp-align-top"),b.fixedContentPos?b.wrap.css({overflow:b.st.overflowY,overflowX:"hidden",overflowY:b.st.overflowY}):b.wrap.css({top:v.scrollTop(),position:"absolute"}),(b.st.fixedBgPos===!1||"auto"===b.st.fixedBgPos&&!b.fixedContentPos)&&b.bgOverlay.css({height:d.height(),position:"absolute"}),b.st.enableEscapeKey&&d.on("keyup"+p,function(a){27===a.keyCode&&b.close()}),v.on("resize"+p,function(){b.updateSize()}),b.st.closeOnContentClick||(f+=" mfp-auto-cursor"),f&&b.wrap.addClass(f);var k=b.wH=v.height(),n={};if(b.fixedContentPos&&b._hasScrollBar(k)){var o=b._getScrollbarSize();o&&(n.marginRight=o)}b.fixedContentPos&&(b.isIE7?a("body, html").css("overflow","hidden"):n.overflow="hidden");var r=b.st.mainClass;return b.isIE7&&(r+=" mfp-ie7"),r&&b._addClassToMFP(r),b.updateItemHTML(),y("BuildControls"),a("html").css(n),b.bgOverlay.add(b.wrap).prependTo(b.st.prependTo||a(document.body)),b._lastFocusedEl=document.activeElement,setTimeout(function(){b.content?(b._addClassToMFP(q),b._setFocus()):b.bgOverlay.addClass(q),d.on("focusin"+p,b._onFocusIn)},16),b.isOpen=!0,b.updateSize(k),y(m),c},close:function(){b.isOpen&&(y(i),b.isOpen=!1,b.st.removalDelay&&!b.isLowIE&&b.supportsTransition?(b._addClassToMFP(r),setTimeout(function(){b._close()},b.st.removalDelay)):b._close())},_close:function(){y(h);var c=r+" "+q+" ";if(b.bgOverlay.detach(),b.wrap.detach(),b.container.empty(),b.st.mainClass&&(c+=b.st.mainClass+" "),b._removeClassFromMFP(c),b.fixedContentPos){var e={marginRight:""};b.isIE7?a("body, html").css("overflow",""):e.overflow="",a("html").css(e)}d.off("keyup"+p+" focusin"+p),b.ev.off(p),b.wrap.attr("class","mfp-wrap").removeAttr("style"),b.bgOverlay.attr("class","mfp-bg"),b.container.attr("class","mfp-container"),!b.st.showCloseBtn||b.st.closeBtnInside&&b.currTemplate[b.currItem.type]!==!0||b.currTemplate.closeBtn&&b.currTemplate.closeBtn.detach(),b.st.autoFocusLast&&b._lastFocusedEl&&a(b._lastFocusedEl).focus(),b.currItem=null,b.content=null,b.currTemplate=null,b.prevHeight=0,y(j)},updateSize:function(a){if(b.isIOS){var c=document.documentElement.clientWidth/window.innerWidth,d=window.innerHeight*c;b.wrap.css("height",d),b.wH=d}else b.wH=a||v.height();b.fixedContentPos||b.wrap.css("height",b.wH),y("Resize")},updateItemHTML:function(){var c=b.items[b.index];b.contentContainer.detach(),b.content&&b.content.detach(),c.parsed||(c=b.parseEl(b.index));var d=c.type;if(y("BeforeChange",[b.currItem?b.currItem.type:"",d]),b.currItem=c,!b.currTemplate[d]){var f=b.st[d]?b.st[d].markup:!1;y("FirstMarkupParse",f),f?b.currTemplate[d]=a(f):b.currTemplate[d]=!0}e&&e!==c.type&&b.container.removeClass("mfp-"+e+"-holder");var g=b["get"+d.charAt(0).toUpperCase()+d.slice(1)](c,b.currTemplate[d]);b.appendContent(g,d),c.preloaded=!0,y(n,c),e=c.type,b.container.prepend(b.contentContainer),y("AfterChange")},appendContent:function(a,c){b.content=a,a?b.st.showCloseBtn&&b.st.closeBtnInside&&b.currTemplate[c]===!0?b.content.find(".mfp-close").length||b.content.append(z()):b.content=a:b.content="",y(k),b.container.addClass("mfp-"+c+"-holder"),b.contentContainer.append(b.content)},parseEl:function(c){var d,e=b.items[c];if(e.tagName?e={el:a(e)}:(d=e.type,e={data:e,src:e.src}),e.el){for(var f=b.types,g=0;g<f.length;g++)if(e.el.hasClass("mfp-"+f[g])){d=f[g];break}e.src=e.el.attr("data-mfp-src"),e.src||(e.src=e.el.attr("href"))}return e.type=d||b.st.type||"inline",e.index=c,e.parsed=!0,b.items[c]=e,y("ElementParse",e),b.items[c]},addGroup:function(a,c){var d=function(d){d.mfpEl=this,b._openClick(d,a,c)};c||(c={});var e="click.magnificPopup";c.mainEl=a,c.items?(c.isObj=!0,a.off(e).on(e,d)):(c.isObj=!1,c.delegate?a.off(e).on(e,c.delegate,d):(c.items=a,a.off(e).on(e,d)))},_openClick:function(c,d,e){var f=void 0!==e.midClick?e.midClick:a.magnificPopup.defaults.midClick;if(f||!(2===c.which||c.ctrlKey||c.metaKey||c.altKey||c.shiftKey)){var g=void 0!==e.disableOn?e.disableOn:a.magnificPopup.defaults.disableOn;if(g)if(a.isFunction(g)){if(!g.call(b))return!0}else if(v.width()<g)return!0;c.type&&(c.preventDefault(),b.isOpen&&c.stopPropagation()),e.el=a(c.mfpEl),e.delegate&&(e.items=d.find(e.delegate)),b.open(e)}},updateStatus:function(a,d){if(b.preloader){c!==a&&b.container.removeClass("mfp-s-"+c),d||"loading"!==a||(d=b.st.tLoading);var e={status:a,text:d};y("UpdateStatus",e),a=e.status,d=e.text,b.preloader.html(d),b.preloader.find("a").on("click",function(a){a.stopImmediatePropagation()}),b.container.addClass("mfp-s-"+a),c=a}},_checkIfClose:function(c){if(!a(c).hasClass(s)){var d=b.st.closeOnContentClick,e=b.st.closeOnBgClick;if(d&&e)return!0;if(!b.content||a(c).hasClass("mfp-close")||b.preloader&&c===b.preloader[0])return!0;if(c===b.content[0]||a.contains(b.content[0],c)){if(d)return!0}else if(e&&a.contains(document,c))return!0;return!1}},_addClassToMFP:function(a){b.bgOverlay.addClass(a),b.wrap.addClass(a)},_removeClassFromMFP:function(a){this.bgOverlay.removeClass(a),b.wrap.removeClass(a)},_hasScrollBar:function(a){return(b.isIE7?d.height():document.body.scrollHeight)>(a||v.height())},_setFocus:function(){(b.st.focus?b.content.find(b.st.focus).eq(0):b.wrap).focus()},_onFocusIn:function(c){return c.target===b.wrap[0]||a.contains(b.wrap[0],c.target)?void 0:(b._setFocus(),!1)},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(l,[b,c,d]),a.each(c,function(a,c){if(void 0===c||c===!1)return!0;if(e=a.split("_"),e.length>1){var d=b.find(p+"-"+e[0]);if(d.length>0){var f=e[1];"replaceWith"===f?d[0]!==c[0]&&d.replaceWith(c):"img"===f?d.is("img")?d.attr("src",c):d.replaceWith('<img src="'+c+'" class="'+d.attr("class")+'" />'):d.attr(e[1],c)}}else b.find(p+"-"+a).html(c)})},_getScrollbarSize:function(){if(void 0===b.scrollbarSize){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),b.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return b.scrollbarSize}},a.magnificPopup={instance:null,proto:t.prototype,modules:[],open:function(b,c){return A(),b=b?a.extend(!0,{},b):{},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">&#215;</button>',tClose:"Close (Esc)",tLoading:"Loading...",autoFocusLast:!0}},a.fn.magnificPopup=function(c){A();var d=a(this);if("string"==typeof c)if("open"===c){var e,f=u?d.data("magnificPopup"):d[0].magnificPopup,g=parseInt(arguments[1],10)||0;f.items?e=f.items[g]:(e=d,f.delegate&&(e=e.find(f.delegate)),e=e.eq(g)),b._openClick({mfpEl:e},d,f)}else b.isOpen&&b[c].apply(b,Array.prototype.slice.call(arguments,1));else c=a.extend(!0,{},c),u?d.data("magnificPopup",c):d[0].magnificPopup=c,b.addGroup(d,c);return d};var C,D,E,F="inline",G=function(){E&&(D.after(E.addClass(C)).detach(),E=null)};a.magnificPopup.registerModule(F,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){b.types.push(F),w(h+"."+F,function(){G()})},getInline:function(c,d){if(G(),c.src){var e=b.st.inline,f=a(c.src);if(f.length){var g=f[0].parentNode;g&&g.tagName&&(D||(C=e.hiddenClass,D=x(C),C="mfp-"+C),E=f.after(D).detach().removeClass(C)),b.updateStatus("ready")}else b.updateStatus("error",e.tNotFound),f=a("<div>");return c.inlineElement=f,f}return b.updateStatus("ready"),b._parseMarkup(d,{},c),d}}});var H,I="ajax",J=function(){H&&a(document.body).removeClass(H)},K=function(){J(),b.req&&b.req.abort()};a.magnificPopup.registerModule(I,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){b.types.push(I),H=b.st.ajax.cursor,w(h+"."+I,K),w("BeforeChange."+I,K)},getAjax:function(c){H&&a(document.body).addClass(H),b.updateStatus("loading");var d=a.extend({url:c.src,success:function(d,e,f){var g={data:d,xhr:f};y("ParseAjax",g),b.appendContent(a(g.data),I),c.finished=!0,J(),b._setFocus(),setTimeout(function(){b.wrap.addClass(q)},16),b.updateStatus("ready"),y("AjaxContentAdded")},error:function(){J(),c.finished=c.loadError=!0,b.updateStatus("error",b.st.ajax.tError.replace("%url%",c.src))}},b.st.ajax.settings);return b.req=a.ajax(d),""}}});var L,M=function(c){if(c.data&&void 0!==c.data.title)return c.data.title;var d=b.st.image.titleSrc;if(d){if(a.isFunction(d))return d.call(b,c);if(c.el)return c.el.attr(d)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var c=b.st.image,d=".image";b.types.push("image"),w(m+d,function(){"image"===b.currItem.type&&c.cursor&&a(document.body).addClass(c.cursor)}),w(h+d,function(){c.cursor&&a(document.body).removeClass(c.cursor),v.off("resize"+p)}),w("Resize"+d,b.resizeImage),b.isLowIE&&w("AfterChange",b.resizeImage)},resizeImage:function(){var a=b.currItem;if(a&&a.img&&b.st.image.verticalFit){var c=0;b.isLowIE&&(c=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",b.wH-c)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,L&&clearInterval(L),a.isCheckingImgSize=!1,y("ImageHasSize",a),a.imgHidden&&(b.content&&b.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var c=0,d=a.img[0],e=function(f){L&&clearInterval(L),L=setInterval(function(){return d.naturalWidth>0?void b._onImageHasSize(a):(c>200&&clearInterval(L),c++,void(3===c?e(10):40===c?e(50):100===c&&e(500)))},f)};e(1)},getImage:function(c,d){var e=0,f=function(){c&&(c.img[0].complete?(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("ready")),c.hasSize=!0,c.loaded=!0,y("ImageLoadComplete")):(e++,200>e?setTimeout(f,100):g()))},g=function(){c&&(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("error",h.tError.replace("%url%",c.src))),c.hasSize=!0,c.loaded=!0,c.loadError=!0)},h=b.st.image,i=d.find(".mfp-img");if(i.length){var j=document.createElement("img");j.className="mfp-img",c.el&&c.el.find("img").length&&(j.alt=c.el.find("img").attr("alt")),c.img=a(j).on("load.mfploader",f).on("error.mfploader",g),j.src=c.src,i.is("img")&&(c.img=c.img.clone()),j=c.img[0],j.naturalWidth>0?c.hasSize=!0:j.width||(c.hasSize=!1)}return b._parseMarkup(d,{title:M(c),img_replaceWith:c.img},c),b.resizeImage(),c.hasSize?(L&&clearInterval(L),c.loadError?(d.addClass("mfp-loading"),b.updateStatus("error",h.tError.replace("%url%",c.src))):(d.removeClass("mfp-loading"),b.updateStatus("ready")),d):(b.updateStatus("loading"),c.loading=!0,c.hasSize||(c.imgHidden=!0,d.addClass("mfp-loading"),b.findImageSize(c)),d)}}});var N,O=function(){return void 0===N&&(N=void 0!==document.createElement("p").style.MozTransform),N};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a,c=b.st.zoom,d=".zoom";if(c.enabled&&b.supportsTransition){var e,f,g=c.duration,j=function(a){var b=a.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+c.duration/1e3+"s "+c.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,b.css(e),b},k=function(){b.content.css("visibility","visible")};w("BuildControls"+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.content.css("visibility","hidden"),a=b._getItemToZoom(),!a)return void k();f=j(a),f.css(b._getOffset()),b.wrap.append(f),e=setTimeout(function(){f.css(b._getOffset(!0)),e=setTimeout(function(){k(),setTimeout(function(){f.remove(),a=f=null,y("ZoomAnimationEnded")},16)},g)},16)}}),w(i+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.st.removalDelay=g,!a){if(a=b._getItemToZoom(),!a)return;f=j(a)}f.css(b._getOffset(!0)),b.wrap.append(f),b.content.css("visibility","hidden"),setTimeout(function(){f.css(b._getOffset())},16)}}),w(h+d,function(){b._allowZoom()&&(k(),f&&f.remove(),a=null)})}},_allowZoom:function(){return"image"===b.currItem.type},_getItemToZoom:function(){return b.currItem.hasSize?b.currItem.img:!1},_getOffset:function(c){var d;d=c?b.currItem.img:b.st.zoom.opener(b.currItem.el||b.currItem);var e=d.offset(),f=parseInt(d.css("padding-top"),10),g=parseInt(d.css("padding-bottom"),10);e.top-=a(window).scrollTop()-f;var h={width:d.width(),height:(u?d.innerHeight():d[0].offsetHeight)-g-f};return O()?h["-moz-transform"]=h.transform="translate("+e.left+"px,"+e.top+"px)":(h.left=e.left,h.top=e.top),h}}});var P="iframe",Q="//about:blank",R=function(a){if(b.currTemplate[P]){var c=b.currTemplate[P].find("iframe");c.length&&(a||(c[0].src=Q),b.isIE8&&c.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(P,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){b.types.push(P),w("BeforeChange",function(a,b,c){b!==c&&(b===P?R():c===P&&R(!0))}),w(h+"."+P,function(){R()})},getIframe:function(c,d){var e=c.src,f=b.st.iframe;a.each(f.patterns,function(){return e.indexOf(this.index)>-1?(this.id&&(e="string"==typeof this.id?e.substr(e.lastIndexOf(this.id)+this.id.length,e.length):this.id.call(this,e)),e=this.src.replace("%id%",e),!1):void 0});var g={};return f.srcAction&&(g[f.srcAction]=e),b._parseMarkup(d,g,c),b.updateStatus("ready"),d}}});var S=function(a){var c=b.items.length;return a>c-1?a-c:0>a?c+a:a},T=function(a,b,c){return a.replace(/%curr%/gi,b+1).replace(/%total%/gi,c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var c=b.st.gallery,e=".mfp-gallery",g=Boolean(a.fn.mfpFastClick);return b.direction=!0,c&&c.enabled?(f+=" mfp-gallery",w(m+e,function(){c.navigateByImgClick&&b.wrap.on("click"+e,".mfp-img",function(){return b.items.length>1?(b.next(),!1):void 0}),d.on("keydown"+e,function(a){37===a.keyCode?b.prev():39===a.keyCode&&b.next()})}),w("UpdateStatus"+e,function(a,c){c.text&&(c.text=T(c.text,b.currItem.index,b.items.length))}),w(l+e,function(a,d,e,f){var g=b.items.length;e.counter=g>1?T(c.tCounter,f.index,g):""}),w("BuildControls"+e,function(){if(b.items.length>1&&c.arrows&&!b.arrowLeft){var d=c.arrowMarkup,e=b.arrowLeft=a(d.replace(/%title%/gi,c.tPrev).replace(/%dir%/gi,"left")).addClass(s),f=b.arrowRight=a(d.replace(/%title%/gi,c.tNext).replace(/%dir%/gi,"right")).addClass(s),h=g?"mfpFastClick":"click";e[h](function(){b.prev()}),f[h](function(){b.next()}),b.isIE7&&(x("b",e[0],!1,!0),x("a",e[0],!1,!0),x("b",f[0],!1,!0),x("a",f[0],!1,!0)),b.container.append(e.add(f))}}),w(n+e,function(){b._preloadTimeout&&clearTimeout(b._preloadTimeout),b._preloadTimeout=setTimeout(function(){b.preloadNearbyImages(),b._preloadTimeout=null},16)}),void w(h+e,function(){d.off(e),b.wrap.off("click"+e),b.arrowLeft&&g&&b.arrowLeft.add(b.arrowRight).destroyMfpFastClick(),b.arrowRight=b.arrowLeft=null})):!1},next:function(){b.direction=!0,b.index=S(b.index+1),b.updateItemHTML()},prev:function(){b.direction=!1,b.index=S(b.index-1),b.updateItemHTML()},goTo:function(a){b.direction=a>=b.index,b.index=a,b.updateItemHTML()},preloadNearbyImages:function(){var a,c=b.st.gallery.preload,d=Math.min(c[0],b.items.length),e=Math.min(c[1],b.items.length);for(a=1;a<=(b.direction?e:d);a++)b._preloadItem(b.index+a);for(a=1;a<=(b.direction?d:e);a++)b._preloadItem(b.index-a)},_preloadItem:function(c){if(c=S(c),!b.items[c].preloaded){var d=b.items[c];d.parsed||(d=b.parseEl(c)),y("LazyLoad",d),"image"===d.type&&(d.img=a('<img class="mfp-img" />').on("load.mfploader",function(){d.hasSize=!0}).on("error.mfploader",function(){d.hasSize=!0,d.loadError=!0,y("LazyLoadError",d)}).attr("src",d.src)),d.preloaded=!0}}}});var U="retina";a.magnificPopup.registerModule(U,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=b.st.retina,c=a.ratio;c=isNaN(c)?c():c,c>1&&(w("ImageHasSize."+U,function(a,b){b.img.css({"max-width":b.img[0].naturalWidth/c,width:"100%"})}),w("ElementParse."+U,function(b,d){d.src=a.replaceSrc(d,c)}))}}}}),function(){var b=1e3,c="ontouchstart"in window,d=function(){v.off("touchmove"+f+" touchend"+f)},e="mfpFastClick",f="."+e;a.fn.mfpFastClick=function(e){return a(this).each(function(){var g,h=a(this);if(c){var i,j,k,l,m,n;h.on("touchstart"+f,function(a){l=!1,n=1,m=a.originalEvent?a.originalEvent.touches[0]:a.touches[0],j=m.clientX,k=m.clientY,v.on("touchmove"+f,function(a){m=a.originalEvent?a.originalEvent.touches:a.touches,n=m.length,m=m[0],(Math.abs(m.clientX-j)>10||Math.abs(m.clientY-k)>10)&&(l=!0,d())}).on("touchend"+f,function(a){d(),l||n>1||(g=!0,a.preventDefault(),clearTimeout(i),i=setTimeout(function(){g=!1},b),e())})})}h.on("click"+f,function(){g||e()})})},a.fn.destroyMfpFastClick=function(){a(this).off("touchstart"+f+" click"+f),c&&v.off("touchmove"+f+" touchend"+f)}}(),A()});
assets/mag-popup/magnific-popup.css ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Magnific Popup CSS */
2
+ .mfp-bg {
3
+ top:0;
4
+ left:0;
5
+ width:100%;
6
+ height:100%;
7
+ z-index:1042;
8
+ overflow:hidden;
9
+ position:fixed;
10
+ background:#0b0b0b;
11
+ opacity:0.8;
12
+ filter:alpha(opacity=80); }
13
+ .mfp-wrap {
14
+ top:0;
15
+ left:0;
16
+ width:100%;
17
+ height:100%;
18
+ z-index:1043;
19
+ position:fixed;
20
+ outline:none !important;
21
+ -webkit-backface-visibility:hidden; }
22
+ .mfp-container {
23
+ text-align:center;
24
+ position:absolute;
25
+ width:100%;
26
+ height:100%;
27
+ left:0;
28
+ top:0;
29
+ padding:0 8px;
30
+ -webkit-box-sizing:border-box;
31
+ -moz-box-sizing:border-box;
32
+ box-sizing:border-box; }
33
+ .mfp-container:before {
34
+ content:'';
35
+ display:inline-block;
36
+ height:100%;
37
+ vertical-align:middle; }
38
+ .mfp-align-top .mfp-container:before {
39
+ display:none; }
40
+ .mfp-content {
41
+ position:relative;
42
+ display:inline-block;
43
+ vertical-align:middle;
44
+ margin:0 auto;
45
+ text-align:left;
46
+ z-index:1045; }
47
+ .mfp-inline-holder .mfp-content,
48
+ .mfp-ajax-holder .mfp-content {
49
+ width:100%;
50
+ cursor:auto; }
51
+ .mfp-ajax-cur {
52
+ cursor:progress; }
53
+ .mfp-zoom-out-cur, .mfp-zoom-out-cur .mfp-image-holder .mfp-close {
54
+ cursor:-moz-zoom-out;
55
+ cursor:-webkit-zoom-out;
56
+ cursor:zoom-out; }
57
+ .mfp-zoom {
58
+ cursor:pointer;
59
+ cursor:-webkit-zoom-in;
60
+ cursor:-moz-zoom-in;
61
+ cursor:zoom-in; }
62
+ .mfp-auto-cursor .mfp-content {
63
+ cursor:auto; }
64
+ .mfp-close,
65
+ .mfp-arrow,
66
+ .mfp-preloader,
67
+ .mfp-counter {
68
+ -webkit-user-select:none;
69
+ -moz-user-select:none;
70
+ user-select:none; }
71
+ .mfp-loading.mfp-figure {
72
+ display:none; }
73
+ .mfp-hide {
74
+ display:none !important; }
75
+ .mfp-preloader {
76
+ color:#cccccc;
77
+ position:absolute;
78
+ top:50%;
79
+ width:auto;
80
+ text-align:center;
81
+ margin-top:-0.8em;
82
+ left:8px;
83
+ right:8px;
84
+ z-index:1044; }
85
+ .mfp-preloader a {
86
+ color:#cccccc; }
87
+ .mfp-preloader a:hover {
88
+ color:#ffffff; }
89
+ .mfp-s-ready .mfp-preloader {
90
+ display:none; }
91
+ .mfp-s-error .mfp-content {
92
+ display:none; }
93
+ button.mfp-close,
94
+ button.mfp-arrow {
95
+ overflow:visible;
96
+ cursor:pointer;
97
+ background:transparent;
98
+ border:0;
99
+ -webkit-appearance:none;
100
+ display:block;
101
+ outline:none;
102
+ padding:0;
103
+ z-index:1046;
104
+ -webkit-box-shadow:none;
105
+ box-shadow:none; }
106
+ button::-moz-focus-inner {
107
+ padding:0;
108
+ border:0; }
109
+ .mfp-close {
110
+ width:44px;
111
+ height:44px;
112
+ line-height:44px;
113
+ position:absolute;
114
+ right:0;
115
+ top:0;
116
+ text-decoration:none;
117
+ text-align:center;
118
+ opacity:0.65;
119
+ filter:alpha(opacity=65);
120
+ padding:0 0 18px 10px;
121
+ color:#ffffff;
122
+ font-style:normal;
123
+ font-size:28px;
124
+ font-family:Arial, Baskerville, monospace; }
125
+ .mfp-close:hover,
126
+ .mfp-close:focus {
127
+ opacity:1;
128
+ filter:alpha(opacity=100); }
129
+ .mfp-close:active {
130
+ top:1px; }
131
+ .mfp-close-btn-in .mfp-close {
132
+ color:#333333; }
133
+ .mfp-image-holder .mfp-close,
134
+ .mfp-iframe-holder .mfp-close {
135
+ color:#ffffff;
136
+ right:-6px;
137
+ text-align:right;
138
+ padding-right:6px;
139
+ width:100%; }
140
+ .mfp-counter {
141
+ position:absolute;
142
+ top:0;
143
+ right:0;
144
+ color:#cccccc;
145
+ font-size:12px;
146
+ line-height:18px;
147
+ white-space:nowrap; }
148
+ .mfp-arrow {
149
+ position:absolute;
150
+ opacity:0.65;
151
+ filter:alpha(opacity=65);
152
+ margin:0;
153
+ top:50%;
154
+ margin-top:-55px;
155
+ padding:0;
156
+ width:90px;
157
+ height:110px;
158
+ -webkit-tap-highlight-color:transparent; }
159
+ .mfp-arrow:active {
160
+ margin-top:-54px; }
161
+ .mfp-arrow:hover,
162
+ .mfp-arrow:focus {
163
+ opacity:1;
164
+ filter:alpha(opacity=100); }
165
+ .mfp-arrow:before,
166
+ .mfp-arrow:after,
167
+ .mfp-arrow .mfp-b,
168
+ .mfp-arrow .mfp-a {
169
+ content:'';
170
+ display:block;
171
+ width:0;
172
+ height:0;
173
+ position:absolute;
174
+ left:0;
175
+ top:0;
176
+ margin-top:35px;
177
+ margin-left:35px;
178
+ border:medium inset transparent; }
179
+ .mfp-arrow:after,
180
+ .mfp-arrow .mfp-a {
181
+ border-top-width:13px;
182
+ border-bottom-width:13px;
183
+ top:8px; }
184
+ .mfp-arrow:before,
185
+ .mfp-arrow .mfp-b {
186
+ border-top-width:21px;
187
+ border-bottom-width:21px;
188
+ opacity:0.7; }
189
+ .mfp-arrow-left {
190
+ left:0; }
191
+ .mfp-arrow-left:after,
192
+ .mfp-arrow-left .mfp-a {
193
+ border-right:17px solid #ffffff;
194
+ margin-left:31px; }
195
+ .mfp-arrow-left:before,
196
+ .mfp-arrow-left .mfp-b {
197
+ margin-left:25px;
198
+ border-right:27px solid #3f3f3f; }
199
+ .mfp-arrow-right {
200
+ right:0; }
201
+ .mfp-arrow-right:after,
202
+ .mfp-arrow-right .mfp-a {
203
+ border-left:17px solid #ffffff;
204
+ margin-left:39px; }
205
+ .mfp-arrow-right:before,
206
+ .mfp-arrow-right .mfp-b {
207
+ border-left:27px solid #3f3f3f; }
208
+ .mfp-iframe-holder {
209
+ padding-top:40px;
210
+ padding-bottom:40px; }
211
+ .mfp-iframe-holder .mfp-content {
212
+ line-height:0;
213
+ width:100%;
214
+ max-width:900px; }
215
+ .mfp-iframe-holder .mfp-close {
216
+ top:-40px; }
217
+ .mfp-iframe-scaler {
218
+ width:100%;
219
+ height:0;
220
+ overflow:hidden;
221
+ padding-top:56.25%; }
222
+ .mfp-iframe-scaler iframe {
223
+ position:absolute;
224
+ display:block;
225
+ top:0;
226
+ left:0;
227
+ width:100%;
228
+ height:100%;
229
+ box-shadow:0 0 8px rgba(0, 0, 0, 0.6);
230
+ background:#000000; }
231
+ /* Main image in popup */
232
+ img.mfp-img {
233
+ width:auto;
234
+ max-width:100%;
235
+ height:auto;
236
+ display:block;
237
+ line-height:0;
238
+ -webkit-box-sizing:border-box;
239
+ -moz-box-sizing:border-box;
240
+ box-sizing:border-box;
241
+ padding:40px 0 40px;
242
+ margin:0 auto; }
243
+ /* The shadow behind the image */
244
+ .mfp-figure {
245
+ line-height:0; }
246
+ .mfp-figure:after {
247
+ content:'';
248
+ position:absolute;
249
+ left:0;
250
+ top:40px;
251
+ bottom:40px;
252
+ display:block;
253
+ right:0;
254
+ width:auto;
255
+ height:auto;
256
+ z-index:-1;
257
+ box-shadow:0 0 8px rgba(0, 0, 0, 0.6);
258
+ background:#444444; }
259
+ .mfp-figure small {
260
+ color:#bdbdbd;
261
+ display:block;
262
+ font-size:12px;
263
+ line-height:14px; }
264
+ .mfp-figure figure {
265
+ margin:0; }
266
+ .mfp-bottom-bar {
267
+ margin-top:-36px;
268
+ position:absolute;
269
+ top:100%;
270
+ left:0;
271
+ width:100%;
272
+ cursor:auto; }
273
+ .mfp-title {
274
+ text-align:left;
275
+ line-height:18px;
276
+ color:#f3f3f3;
277
+ word-wrap:break-word;
278
+ padding-right:36px; }
279
+ .mfp-image-holder .mfp-content {
280
+ max-width:100%; }
281
+ .mfp-gallery .mfp-image-holder .mfp-figure {
282
+ cursor:pointer; }
283
+ @media screen and (max-width:800px) and (orientation:landscape), screen and (max-height:300px) {
284
+ /**
285
+ * Remove all paddings around the image on small screen
286
+ */
287
+ .mfp-img-mobile .mfp-image-holder {
288
+ padding-left:0;
289
+ padding-right:0; }
290
+ .mfp-img-mobile img.mfp-img {
291
+ padding:0; }
292
+ .mfp-img-mobile .mfp-figure:after {
293
+ top:0;
294
+ bottom:0; }
295
+ .mfp-img-mobile .mfp-figure small {
296
+ display:inline;
297
+ margin-left:5px; }
298
+ .mfp-img-mobile .mfp-bottom-bar {
299
+ background:rgba(0, 0, 0, 0.6);
300
+ bottom:0;
301
+ margin:0;
302
+ top:auto;
303
+ padding:3px 5px;
304
+ position:fixed;
305
+ -webkit-box-sizing:border-box;
306
+ -moz-box-sizing:border-box;
307
+ box-sizing:border-box; }
308
+ .mfp-img-mobile .mfp-bottom-bar:empty {
309
+ padding:0; }
310
+ .mfp-img-mobile .mfp-counter {
311
+ right:5px;
312
+ top:3px; }
313
+ .mfp-img-mobile .mfp-close {
314
+ top:0;
315
+ right:0;
316
+ width:35px;
317
+ height:35px;
318
+ line-height:35px;
319
+ background:rgba(0, 0, 0, 0.6);
320
+ position:fixed;
321
+ text-align:center;
322
+ padding:0; }
323
+ }
324
+ @media all and (max-width:900px) {
325
+ .mfp-arrow {
326
+ -webkit-transform:scale(0.75);
327
+ transform:scale(0.75); }
328
+ .mfp-arrow-left {
329
+ -webkit-transform-origin:0;
330
+ transform-origin:0; }
331
+ .mfp-arrow-right {
332
+ -webkit-transform-origin:100%;
333
+ transform-origin:100%; }
334
+ .mfp-container {
335
+ padding-left:6px;
336
+ padding-right:6px; }
337
+ }
338
+ .mfp-ie7 .mfp-img {
339
+ padding:0; }
340
+ .mfp-ie7 .mfp-bottom-bar {
341
+ width:600px;
342
+ left:50%;
343
+ margin-left:-300px;
344
+ margin-top:5px;
345
+ padding-bottom:5px; }
346
+ .mfp-ie7 .mfp-container {
347
+ padding:0; }
348
+ .mfp-ie7 .mfp-content {
349
+ padding-top:44px; }
350
+ .mfp-ie7 .mfp-close {
351
+ top:0;
352
+ right:0;
353
+ padding-top:0; }
assets/mediaelement/bigplay.svg CHANGED
File without changes
assets/mediaelement/controls.svg CHANGED
File without changes
assets/mediaelement/flashmediaelement.swf CHANGED
File without changes
assets/mediaelement/loading.gif CHANGED
File without changes
assets/mediaelement/mediaelement-and-player.min.js CHANGED
File without changes
assets/mediaelement/mediaelementplayer.min.css CHANGED
File without changes
assets/mediaelement/silverlightmediaelement.xap CHANGED
File without changes
assets/mousetrap/mousetrap.min.js CHANGED
File without changes
assets/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css CHANGED
File without changes
assets/plupload/jquery.plupload.queue/img/backgrounds.gif CHANGED
File without changes
assets/plupload/jquery.plupload.queue/img/delete.gif CHANGED
File without changes
assets/plupload/jquery.plupload.queue/img/done.gif CHANGED
File without changes
assets/plupload/jquery.plupload.queue/img/error.gif CHANGED
File without changes
assets/plupload/jquery.plupload.queue/img/throbber.gif CHANGED
File without changes
assets/plupload/jquery.plupload.queue/jquery.plupload.queue.js CHANGED
File without changes
assets/plupload/license.txt CHANGED
File without changes
assets/plupload/plupload.flash.js CHANGED
File without changes
assets/plupload/plupload.flash.swf CHANGED
File without changes
assets/plupload/plupload.html4.js CHANGED
File without changes
assets/plupload/plupload.html5.js CHANGED
File without changes
assets/plupload/plupload.js CHANGED
File without changes
assets/swf/swfaddress.js CHANGED
File without changes
assets/swf/swfobject.js CHANGED
File without changes
config/setup.php CHANGED
@@ -9,15 +9,30 @@
9
  * @access internal
10
  * @return array
11
  */
12
- function gmedia_default_options()
13
- {
14
 
15
- $gm['site_email'] = '';
16
- $gm['site_category'] = '';
17
- $gm['site_ID'] = '';
18
- $gm['mobile_app'] = 0;
 
19
 
20
- $gm['uninstall_dropdata'] = 'all'; // can be 'all', 'none', 'db'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  $gm['in_tag_orderby'] = 'ID';
23
  $gm['in_tag_order'] = 'DESC';
@@ -26,7 +41,7 @@ function gmedia_default_options()
26
 
27
  $gm['isolation_mode'] = '0';
28
  $gm['shortcode_raw'] = '0';
29
- $gm['debug_mode'] = WP_DEBUG ? '1' : '';
30
 
31
  $gm['endpoint'] = 'gmedia';
32
  $gm['gmediacloud_module'] = '';
@@ -91,10 +106,10 @@ function gmedia_default_options()
91
 
92
  $gm['gm_screen_options']['per_page_sort_gmedia'] = 60;
93
 
94
- $gm['gm_screen_options']['per_page_gmedia'] = 30;
95
- $gm['gm_screen_options']['orderby_gmedia'] = 'ID';
96
- $gm['gm_screen_options']['sortorder_gmedia'] = 'DESC';
97
- $gm['gm_screen_options']['display_mode_gmedia'] = 'list';
98
  $gm['gm_screen_options']['grid_cell_fit_gmedia'] = false;
99
 
100
  $gm['gm_screen_options']['per_page_gmedia_terms'] = 30;
@@ -123,20 +138,19 @@ function gmedia_default_options()
123
  /**
124
  * sets gmedia capabilities to administrator role
125
  **/
126
- function gmedia_capabilities()
127
- {
128
  global $gmCore;
129
  // Set the capabilities for the administrator
130
  $role = get_role('administrator');
131
  // We need this role, no other chance
132
- if (empty($role)) {
133
  update_option("gmediaInitCheck", __('Sorry, Gmedia Gallery works only with a role called administrator', 'grand-media'));
134
 
135
  return;
136
  }
137
  $capabilities = $gmCore->plugin_capabilities();
138
  $capabilities = apply_filters('gmedia_capabilities', $capabilities);
139
- foreach ($capabilities as $cap) {
140
  $role->add_cap($cap);
141
  }
142
  }
@@ -148,13 +162,12 @@ function gmedia_capabilities()
148
  * @access internal
149
  * @return void
150
  **/
151
- function gmedia_install()
152
- {
153
  /** @var $wpdb wpdb */
154
  global $wpdb, $gmGallery, $gmCore;
155
 
156
  // Check for capability
157
- if (! current_user_can('activate_plugins')) {
158
  return;
159
  }
160
 
@@ -166,11 +179,11 @@ function gmedia_install()
166
  // add charset & collate like wp core
167
  $charset_collate = '';
168
 
169
- if ($wpdb->has_cap('collation')) {
170
- if (! empty($wpdb->charset)) {
171
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
172
  }
173
- if (! empty($wpdb->collate)) {
174
  $charset_collate .= " COLLATE $wpdb->collate";
175
  }
176
  }
@@ -181,7 +194,7 @@ function gmedia_install()
181
  $gmedia_term_meta = $wpdb->prefix . 'gmedia_term_meta';
182
  $gmedia_term_relationships = $wpdb->prefix . 'gmedia_term_relationships';
183
 
184
- if ($wpdb->get_var("show tables like '$gmedia'") != $gmedia) {
185
  $sql = "CREATE TABLE {$gmedia} (
186
  ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
187
  author BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
@@ -192,16 +205,18 @@ function gmedia_install()
192
  link VARCHAR(255) NOT NULL DEFAULT '',
193
  modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
194
  mime_type VARCHAR(100) NOT NULL DEFAULT '',
195
- status VARCHAR(20) NOT NULL DEFAULT 'public',
 
196
  PRIMARY KEY (ID),
197
  KEY gmuid (gmuid),
198
  KEY type_status_date (mime_type,status,date,ID),
199
- KEY author (author)
 
200
  ) {$charset_collate}";
201
  dbDelta($sql);
202
  }
203
 
204
- if ($wpdb->get_var("show tables like '$gmedia_meta'") != $gmedia_meta) {
205
  $sql = "CREATE TABLE {$gmedia_meta} (
206
  meta_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
207
  gmedia_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
@@ -214,7 +229,7 @@ function gmedia_install()
214
  dbDelta($sql);
215
  }
216
 
217
- if ($wpdb->get_var("show tables like '$gmedia_term'") != $gmedia_term) {
218
  $sql = "CREATE TABLE {$gmedia_term} (
219
  term_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
220
  name VARCHAR(200) NOT NULL DEFAULT '',
@@ -222,7 +237,7 @@ function gmedia_install()
222
  description LONGTEXT NOT NULL,
223
  global BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
224
  count BIGINT(20) NOT NULL DEFAULT '0',
225
- status VARCHAR(20) NOT NULL DEFAULT 'public',
226
  PRIMARY KEY (term_id),
227
  KEY taxonomy (taxonomy),
228
  KEY name (name)
@@ -230,7 +245,7 @@ function gmedia_install()
230
  dbDelta($sql);
231
  }
232
 
233
- if ($wpdb->get_var("show tables like '$gmedia_term_meta'") != $gmedia_term_meta) {
234
  $sql = "CREATE TABLE {$gmedia_term_meta} (
235
  meta_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
236
  gmedia_term_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
@@ -243,7 +258,7 @@ function gmedia_install()
243
  dbDelta($sql);
244
  }
245
 
246
- if ($wpdb->get_var("show tables like '$gmedia_term_relationships'") != $gmedia_term_relationships) {
247
  $sql = "CREATE TABLE {$gmedia_term_relationships} (
248
  gmedia_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
249
  gmedia_term_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
@@ -256,22 +271,22 @@ function gmedia_install()
256
  }
257
 
258
  // check one table again, to be sure
259
- if ($wpdb->get_var("show tables like '$gmedia'") != $gmedia) {
260
  update_option("gmediaInitCheck", __('GmediaGallery: Tables could not created, please check your database settings', 'grand-media'));
261
 
262
  return;
263
  }
264
 
265
- if (! get_option('GmediaHashID_salt')) {
266
  $ustr = wp_generate_password(12, false);
267
  add_option('GmediaHashID_salt', $ustr);
268
  }
269
 
270
  // set the default settings, if we didn't upgrade
271
- if (empty($gmGallery->options)) {
272
  $gmGallery->options = gmedia_default_options();
273
  // Set installation date
274
- if (! get_option('gmediaInstallDate')) {
275
  $installDate = time();
276
  add_option('gmediaInstallDate', $installDate);
277
  }
@@ -285,9 +300,14 @@ function gmedia_install()
285
  }
286
 
287
  // try to make gallery dirs if not exists
288
- foreach ($gmGallery->options['folder'] as $folder) {
289
  wp_mkdir_p($gmCore->upload['path'] . '/' . $folder);
290
  }
 
 
 
 
 
291
  }
292
 
293
  /**
@@ -296,13 +316,15 @@ function gmedia_install()
296
  * @access internal
297
  * @return void
298
  */
299
- function gmedia_deactivate()
300
- {
301
- $gm_options = get_option('gmediaOptions');
302
- if ((int)$gm_options['mobile_app']) {
303
- global $gmCore;
304
- $gmCore->app_service('app_deactivate');
305
- }
 
 
306
  // remove & reset the init check option
307
  delete_option('gmediaInitCheck');
308
  }
9
  * @access internal
10
  * @return array
11
  */
12
+ function gmedia_default_options() {
 
13
 
14
+ $gm['site_email'] = '';
15
+ $gm['site_ID'] = '';
16
+ $gm['site_title'] = '';
17
+ $gm['site_description'] = '';
18
+ $gm['mobile_app'] = 1;
19
 
20
+ $gm['gmedia_post_slug'] = 'gmedia';
21
+ $gm['gmedia_exclude_from_search'] = '0';
22
+ $gm['default_gmedia_comment_status'] = 'open'; // can be 'closed', 'open'
23
+
24
+ $gm['gmedia_album_post_slug'] = 'gmedia-album';
25
+ $gm['gmedia_album_exclude_from_search'] = '0';
26
+
27
+ $gm['gmedia_filter_post_slug'] = 'gmedia-filter';
28
+ $gm['gmedia_filter_exclude_from_search'] = '0';
29
+
30
+ $gm['gmedia_gallery_post_slug'] = 'gmedia-gallery';
31
+ $gm['gmedia_gallery_exclude_from_search'] = '0';
32
+
33
+ $gm['default_gmedia_term_comment_status'] = 'closed'; // can be 'closed', 'open'
34
+
35
+ $gm['uninstall_dropdata'] = 'none'; // can be 'all', 'none', 'db'
36
 
37
  $gm['in_tag_orderby'] = 'ID';
38
  $gm['in_tag_order'] = 'DESC';
41
 
42
  $gm['isolation_mode'] = '0';
43
  $gm['shortcode_raw'] = '0';
44
+ $gm['debug_mode'] = WP_DEBUG? '1' : '';
45
 
46
  $gm['endpoint'] = 'gmedia';
47
  $gm['gmediacloud_module'] = '';
106
 
107
  $gm['gm_screen_options']['per_page_sort_gmedia'] = 60;
108
 
109
+ $gm['gm_screen_options']['per_page_gmedia'] = 30;
110
+ $gm['gm_screen_options']['orderby_gmedia'] = 'ID';
111
+ $gm['gm_screen_options']['sortorder_gmedia'] = 'DESC';
112
+ $gm['gm_screen_options']['display_mode_gmedia'] = 'list';
113
  $gm['gm_screen_options']['grid_cell_fit_gmedia'] = false;
114
 
115
  $gm['gm_screen_options']['per_page_gmedia_terms'] = 30;
138
  /**
139
  * sets gmedia capabilities to administrator role
140
  **/
141
+ function gmedia_capabilities() {
 
142
  global $gmCore;
143
  // Set the capabilities for the administrator
144
  $role = get_role('administrator');
145
  // We need this role, no other chance
146
+ if(empty($role)) {
147
  update_option("gmediaInitCheck", __('Sorry, Gmedia Gallery works only with a role called administrator', 'grand-media'));
148
 
149
  return;
150
  }
151
  $capabilities = $gmCore->plugin_capabilities();
152
  $capabilities = apply_filters('gmedia_capabilities', $capabilities);
153
+ foreach($capabilities as $cap) {
154
  $role->add_cap($cap);
155
  }
156
  }
162
  * @access internal
163
  * @return void
164
  **/
165
+ function gmedia_install() {
 
166
  /** @var $wpdb wpdb */
167
  global $wpdb, $gmGallery, $gmCore;
168
 
169
  // Check for capability
170
+ if(!current_user_can('activate_plugins')) {
171
  return;
172
  }
173
 
179
  // add charset & collate like wp core
180
  $charset_collate = '';
181
 
182
+ if($wpdb->has_cap('collation')) {
183
+ if(!empty($wpdb->charset)) {
184
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
185
  }
186
+ if(!empty($wpdb->collate)) {
187
  $charset_collate .= " COLLATE $wpdb->collate";
188
  }
189
  }
194
  $gmedia_term_meta = $wpdb->prefix . 'gmedia_term_meta';
195
  $gmedia_term_relationships = $wpdb->prefix . 'gmedia_term_relationships';
196
 
197
+ if($wpdb->get_var("show tables like '$gmedia'") != $gmedia) {
198
  $sql = "CREATE TABLE {$gmedia} (
199
  ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
200
  author BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
205
  link VARCHAR(255) NOT NULL DEFAULT '',
206
  modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
207
  mime_type VARCHAR(100) NOT NULL DEFAULT '',
208
+ status VARCHAR(20) NOT NULL DEFAULT 'publish',
209
+ post_id BIGINT(20) UNSIGNED DEFAULT NULL,
210
  PRIMARY KEY (ID),
211
  KEY gmuid (gmuid),
212
  KEY type_status_date (mime_type,status,date,ID),
213
+ KEY author (author),
214
+ KEY post_id (post_id)
215
  ) {$charset_collate}";
216
  dbDelta($sql);
217
  }
218
 
219
+ if($wpdb->get_var("show tables like '$gmedia_meta'") != $gmedia_meta) {
220
  $sql = "CREATE TABLE {$gmedia_meta} (
221
  meta_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
222
  gmedia_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
229
  dbDelta($sql);
230
  }
231
 
232
+ if($wpdb->get_var("show tables like '$gmedia_term'") != $gmedia_term) {
233
  $sql = "CREATE TABLE {$gmedia_term} (
234
  term_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
235
  name VARCHAR(200) NOT NULL DEFAULT '',
237
  description LONGTEXT NOT NULL,
238
  global BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
239
  count BIGINT(20) NOT NULL DEFAULT '0',
240
+ status VARCHAR(20) NOT NULL DEFAULT 'publish',
241
  PRIMARY KEY (term_id),
242
  KEY taxonomy (taxonomy),
243
  KEY name (name)
245
  dbDelta($sql);
246
  }
247
 
248
+ if($wpdb->get_var("show tables like '$gmedia_term_meta'") != $gmedia_term_meta) {
249
  $sql = "CREATE TABLE {$gmedia_term_meta} (
250
  meta_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
251
  gmedia_term_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
258
  dbDelta($sql);
259
  }
260
 
261
+ if($wpdb->get_var("show tables like '$gmedia_term_relationships'") != $gmedia_term_relationships) {
262
  $sql = "CREATE TABLE {$gmedia_term_relationships} (
263
  gmedia_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
264
  gmedia_term_id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
271
  }
272
 
273
  // check one table again, to be sure
274
+ if($wpdb->get_var("show tables like '$gmedia'") != $gmedia) {
275
  update_option("gmediaInitCheck", __('GmediaGallery: Tables could not created, please check your database settings', 'grand-media'));
276
 
277
  return;
278
  }
279
 
280
+ if(!get_option('GmediaHashID_salt')) {
281
  $ustr = wp_generate_password(12, false);
282
  add_option('GmediaHashID_salt', $ustr);
283
  }
284
 
285
  // set the default settings, if we didn't upgrade
286
+ if(empty($gmGallery->options)) {
287
  $gmGallery->options = gmedia_default_options();
288
  // Set installation date
289
+ if(!get_option('gmediaInstallDate')) {
290
  $installDate = time();
291
  add_option('gmediaInstallDate', $installDate);
292
  }
300
  }
301
 
302
  // try to make gallery dirs if not exists
303
+ foreach($gmGallery->options['folder'] as $folder) {
304
  wp_mkdir_p($gmCore->upload['path'] . '/' . $folder);
305
  }
306
+
307
+ wp_clear_scheduled_hook('gmedia_app_cronjob');
308
+ wp_schedule_event(time(), 'gmedia_app', 'gmedia_app_cronjob');
309
+
310
+ add_option('gmediaActivated', time());
311
  }
312
 
313
  /**
316
  * @access internal
317
  * @return void
318
  */
319
+ function gmedia_deactivate() {
320
+ global $gmCore;
321
+
322
+ flush_rewrite_rules(false);
323
+
324
+ wp_clear_scheduled_hook('gmedia_app_cronjob');
325
+
326
+ $gmCore->app_service('app_deactivateplugin');
327
+
328
  // remove & reset the init check option
329
  delete_option('gmediaInitCheck');
330
  }
config/update.php CHANGED
@@ -3,13 +3,12 @@
3
  * Update Gmedia plugin
4
  */
5
 
6
- function gmedia_update_admin_notice()
7
- {
8
  ?>
9
  <div id="message" class="updated gmedia-message">
10
- <p><?php _e('<strong>GmediaGallery Data Update Required</strong> &#8211; We need to update your install to the latest version.', 'grand-media'); ?></p>
11
 
12
- <p><?php _e('<strong>Important:</strong> &#8211; GmediaGallery plugin was fully rewritten, so after update you need to check all your created galleries and update modules.', 'grand-media'); ?></p>
13
 
14
  <p><?php _e('The update process may take a little while, so please be patient.', 'grand-media'); ?></p>
15
 
@@ -18,36 +17,72 @@ function gmedia_update_admin_notice()
18
  </p>
19
  </div>
20
  <script type="text/javascript">
21
- jQuery('.gm-update-now').click('click', function () {
22
- return confirm('<?php _e('It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'gmedia'); ?>');
23
  });
24
  </script>
25
  <?php
26
 
27
  }
28
 
29
- function gmedia_wait_admin_notice()
30
- {
31
  ?>
32
  <div id="message" class="updated gmedia-message">
33
- <p><?php _e('<strong>GmediaGallery Updating:</strong> &#8211; GmediaGallery plugin was fully rewritten, so after update you need to check all your created galleries and update modules.', 'grand-media'); ?></p>
34
-
35
  <p><?php _e('The update process may take a little while, so please be patient.', 'grand-media'); ?></p>
36
  </div>
37
  <?php
38
 
39
  }
40
 
41
- function gmedia_do_update()
42
- {
43
- global $wpdb, $gmDB, $gmCore, $gmGallery;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- // 10 minutes execution time
46
- @set_time_limit(10 * 60);
47
 
48
- if (ob_get_level() == 0) {
49
- ob_start();
50
- }
 
 
51
 
52
  // upgrade function changed in WordPress 2.3
53
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
@@ -55,11 +90,11 @@ function gmedia_do_update()
55
  // add charset & collate like wp core
56
  $charset_collate = '';
57
 
58
- if ($wpdb->has_cap('collation')) {
59
- if (! empty($wpdb->charset)) {
60
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
61
  }
62
- if (! empty($wpdb->collate)) {
63
  $charset_collate .= " COLLATE $wpdb->collate";
64
  }
65
  }
@@ -79,11 +114,13 @@ function gmedia_do_update()
79
  link VARCHAR(255) NOT NULL DEFAULT '',
80
  modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
81
  mime_type VARCHAR(100) NOT NULL DEFAULT '',
82
- status VARCHAR(20) NOT NULL DEFAULT 'public',
 
83
  PRIMARY KEY (ID),
84
  KEY gmuid (gmuid),
85
  KEY type_status_date (mime_type,status,date,ID),
86
- KEY author (author)
 
87
  ) {$charset_collate};
88
  CREATE TABLE {$gmedia_term} (
89
  term_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -92,7 +129,7 @@ function gmedia_do_update()
92
  description LONGTEXT NOT NULL,
93
  global BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
94
  count BIGINT(20) NOT NULL DEFAULT '0',
95
- status VARCHAR(20) NOT NULL DEFAULT 'public',
96
  PRIMARY KEY (term_id),
97
  KEY taxonomy (taxonomy),
98
  KEY name (name)
@@ -108,30 +145,69 @@ function gmedia_do_update()
108
  ";
109
  dbDelta($sql);
110
 
111
- echo '<p>' . __('Gmedia database tables updated...', 'grand-media') . '</p><br>';
112
- echo '<script type="text/javascript">
113
- var scroll_down = true;
114
- function ScrollDown() {
115
- if(scroll_down){
116
- window.scrollTo(0,document.body.scrollHeight);
117
- setTimeout(function(){ ScrollDown(); },100);
118
- }
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
- ScrollDown();
121
- window.onload = function() {
122
- ScrollDown();
123
- scroll_down = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
- </script>';
126
 
127
- echo '<p>' . __('Start update images...', 'grand-media') . '</p>';
128
- wp_ob_end_flush_all();
129
 
 
 
 
 
 
130
 
131
  $old_options = get_option('gmediaOptions');
132
  require_once(dirname(__FILE__) . '/setup.php');
133
  $options = gmedia_default_options();
134
- if (isset($old_options['product_name'])) {
135
  $options['license_name'] = $old_options['product_name'];
136
  $options['license_key'] = $old_options['gmedia_key'];
137
  $options['license_key2'] = $old_options['gmedia_key2'];
@@ -140,27 +216,27 @@ window.onload = function() {
140
  $gmGallery->options = $options;
141
 
142
  $fix_files = glob($gmCore->upload['path'] . '/?*.?*', GLOB_NOSORT);
143
- if (! empty($fix_files)) {
144
- foreach ($fix_files as $ff) {
145
  @rename($ff, $gmCore->upload['path'] . '/image/' . basename($ff));
146
  }
147
  }
148
 
149
  $gmedias = $gmDB->get_gmedias(array('mime_type' => 'image/*', 'cache_results' => false));
150
  $files = array();
151
- foreach ($gmedias as $gmedia) {
152
  $files[] = array(
153
- 'id' => $gmedia->ID,
154
- 'file' => $gmCore->upload['path'] . '/image/' . $gmedia->gmuid,
155
  );
156
  }
157
- if (! empty($files)) {
158
  gmedia_images_update($files);
159
  }
160
  $gmCore->delete_folder($gmCore->upload['path'] . '/link');
161
 
162
  // try to make gallery dirs if not exists
163
- foreach ($gmGallery->options['folder'] as $folder) {
164
  wp_mkdir_p($gmCore->upload['path'] . '/' . $folder);
165
  }
166
 
@@ -168,94 +244,224 @@ window.onload = function() {
168
  $wpdb->update($wpdb->prefix . 'gmedia_term', array('taxonomy' => 'gmedia_gallery'), array('taxonomy' => 'gmedia_module'));
169
 
170
  $gmedias = $gmDB->get_gmedias(array('no_found_rows' => true, 'meta_key' => 'link', 'cache_results' => false));
171
- foreach ($gmedias as $gmedia) {
172
  $link = $gmDB->get_metadata('gmedia', $gmedia->ID, 'link', true);
173
- if ($link) {
174
  $wpdb->update($wpdb->prefix . 'gmedia', array('link' => $link), array('ID' => $gmedia->ID));
175
  }
176
  }
177
  $wpdb->delete($wpdb->prefix . 'gmedia_meta', array('meta_key' => 'link'));
178
- //$gmDB->delete_metadata('gmedia', 0, 'link', false, true);
179
-
180
  $wpdb->update($wpdb->prefix . 'gmedia_meta', array('meta_key' => '_cover'), array('meta_key' => 'preview'));
181
 
182
- echo '<p>' . __('Gmedia database data updated...', 'grand-media') . '</p>';
183
- wp_ob_end_flush_all();
 
184
 
185
  $galleries = $gmDB->get_terms('gmedia_gallery');
186
- if ($galleries) {
187
- foreach ($galleries as $gallery) {
188
  $old_meta = $gmDB->get_metadata('gmedia_term', $gallery->term_id);
189
- if (! empty($old_meta)) {
190
  $old_meta = array_map('reset', $old_meta);
191
- //$old_meta = array_map('maybe_unserialize', $old_meta);
192
- if (! isset($old_meta['gMediaQuery'])) {
193
  continue;
194
  }
195
- /*
196
- $old_meta_keys = array_keys($old_meta);
197
- foreach($old_meta_keys as $key){
198
- $wpdb->delete($wpdb->prefix.'gmedia_term_meta', array('gmedia_term_id' => $gallery->term_id, 'meta_key' => $key));
199
- //$gmDB->delete_metadata('gmedia_term', $gallery->term_id, $key);
200
- }
201
- */
202
  $gmedia_category = $gmedia_tag = array();
203
- foreach ($old_meta['gMediaQuery'] as $tab) {
204
- if (isset($tab['cat']) && ! empty($tab['cat'])) {
205
  $gmedia_category[] = $tab['cat'];
206
  }
207
- if (isset($tab['tag__in']) && ! empty($tab['tag__in'])) {
208
  $gmedia_tag = array_merge($gmedia_tag, $tab['tag__in']);
209
  }
210
  }
211
  $query = array();
212
- if (! empty($gmedia_category)) {
213
  $query = array('gmedia_album' => $gmedia_category);
214
- } elseif (! empty($gmedia_tag)) {
215
  $query = array('gmedia_tag' => $gmedia_tag);
216
  }
217
  $gallery_meta = array(
218
- '_edited' => $old_meta['last_edited'],
219
- '_module' => $old_meta['module_name'],
220
- '_query' => $query
221
  );
222
- foreach ($gallery_meta as $key => $value) {
223
  $gmDB->update_metadata('gmedia_term', $gallery->term_id, $key, $value);
224
  }
225
  }
226
  }
227
  }
228
 
229
- echo '<p>' . __('Gmedia Galleries updated...', 'grand-media') . '</p><br><br>';
230
- wp_ob_end_flush_all();
231
 
232
- update_option("gmediaDbVersion", GMEDIA_DBVERSION);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
 
234
- echo '<p>' . __('GmediaGallery plugin update complete.', 'grand-media') . '</p>';
235
  }
236
 
237
  /**
238
  * @param $files
239
  */
240
- function gmedia_images_update($files)
241
- {
242
  global $wpdb, $gmCore, $gmGallery;
243
 
244
- if (ob_get_level() == 0) {
245
- ob_start();
246
- }
247
 
248
  $eol = '</pre>' . PHP_EOL;
249
  $c = count($files);
250
  $i = 0;
251
- foreach ($files as $file) {
252
 
253
  /**
254
  * @var $file
255
  * @var $id
256
  */
257
- if (is_array($file)) {
258
- if (isset($file['file'])) {
259
  extract($file);
260
  } else {
261
  _e('Something went wrong...', 'grand-media');
@@ -263,18 +469,17 @@ function gmedia_images_update($files)
263
  }
264
  }
265
 
266
- wp_ob_end_flush_all();
267
-
268
  $i++;
269
  $prefix = "\n<pre style='display:block;'>$i/$c - ";
270
  $prefix_ko = "\n<pre style='display:block;color:darkred;'>$i/$c - ";
271
 
272
- if (! is_file($file)) {
273
  $fileinfo = $gmCore->fileinfo($file, false);
274
- if (is_file($fileinfo['filepath_original'])) {
275
  @rename($fileinfo['filepath_original'], $fileinfo['filepath']);
276
  } else {
277
- echo $prefix_ko . sprintf(__('File not exists: %s', 'grand-media'), $file) . $eol;
 
278
  continue;
279
  }
280
  }
@@ -282,30 +487,30 @@ function gmedia_images_update($files)
282
  $file_File = $file;
283
  $fileinfo = $gmCore->fileinfo($file, false);
284
 
285
- if ($file_File != $fileinfo['filepath']) {
286
  @rename($file_File, $fileinfo['filepath']);
287
  $wpdb->update($wpdb->prefix . 'gmedia', array('gmuid' => $fileinfo['basename']), array('gmuid' => basename($file_File)));
288
  }
289
 
290
- if ('image' == $fileinfo['dirname']) {
291
  $size = @getimagesize($fileinfo['filepath']);
292
- if (! file_exists($fileinfo['filepath_thumb']) && file_is_displayable_image($fileinfo['filepath'])) {
293
- if (function_exists('memory_get_usage')) {
294
  $extensions = array('1' => 'GIF', '2' => 'JPG', '3' => 'PNG', '6' => 'BMP');
295
- switch ($extensions[$size[2]]) {
296
  case 'GIF':
297
  $CHANNEL = 1;
298
- break;
299
  case 'JPG':
300
  $CHANNEL = $size['channels'];
301
- break;
302
  case 'PNG':
303
  $CHANNEL = 3;
304
- break;
305
  case 'BMP':
306
  default:
307
  $CHANNEL = 6;
308
- break;
309
  }
310
  $MB = 1048576; // number of bytes in 1M
311
  $K64 = 65536; // number of bytes in 64K
@@ -314,40 +519,42 @@ function gmedia_images_update($files)
314
  $memoryNeeded = memory_get_usage() + $memoryNeeded;
315
  $current_limit = @ini_get('memory_limit');
316
  $current_limit_int = intval($current_limit);
317
- if (false !== strpos($current_limit, 'M')) {
318
  $current_limit_int *= $MB;
319
  }
320
- if (false !== strpos($current_limit, 'G')) {
321
  $current_limit_int *= 1024;
322
  }
323
 
324
- if (-1 != $current_limit && $memoryNeeded > $current_limit_int) {
325
  $newLimit = $current_limit_int / $MB + ceil(($memoryNeeded - $current_limit_int) / $MB);
326
  @ini_set('memory_limit', $newLimit . 'M');
327
  }
328
  }
329
 
330
- if (! wp_mkdir_p($fileinfo['dirpath_thumb'])) {
331
- echo $prefix_ko . sprintf(__('Unable to create directory `%s`. Is its parent directory writable by the server?', 'grand-media'),
332
- $fileinfo['dirpath_thumb']) . $eol;
333
  continue;
334
  }
335
- if (! is_writable($fileinfo['dirpath_thumb'])) {
336
  @chmod($fileinfo['dirpath_thumb'], 0755);
337
- if (! is_writable($fileinfo['dirpath_thumb'])) {
338
- echo $prefix_ko . sprintf(__('Directory `%s` is not writable by the server.', 'grand-media'), $fileinfo['dirpath_thumb']) . $eol;
 
339
  continue;
340
  }
341
  }
342
- if (! wp_mkdir_p($fileinfo['dirpath_original'])) {
343
- echo $prefix_ko . sprintf(__('Unable to create directory `%s`. Is its parent directory writable by the server?', 'grand-media'),
344
- $fileinfo['dirpath_original']) . $eol;
345
  continue;
346
  }
347
- if (! is_writable($fileinfo['dirpath_original'])) {
348
  @chmod($fileinfo['dirpath_original'], 0755);
349
- if (! is_writable($fileinfo['dirpath_original'])) {
350
- echo $prefix_ko . sprintf(__('Directory `%s` is not writable by the server.', 'grand-media'), $fileinfo['dirpath_original']) . $eol;
 
351
  continue;
352
  }
353
  }
@@ -356,33 +563,36 @@ function gmedia_images_update($files)
356
  $webimg = $gmGallery->options['image'];
357
  $thumbimg = $gmGallery->options['thumb'];
358
 
359
- $webimg['resize'] = (($webimg['width'] < $size[0]) || ($webimg['height'] < $size[1])) ? true : false;
360
- $thumbimg['resize'] = (($thumbimg['width'] < $size[0]) || ($thumbimg['height'] < $size[1])) ? true : false;
361
 
362
- if ($webimg['resize']) {
363
  rename($fileinfo['filepath'], $fileinfo['filepath_original']);
364
  } else {
365
  copy($fileinfo['filepath'], $fileinfo['filepath_original']);
366
  }
367
- if ($webimg['resize'] || $thumbimg['resize']) {
368
  $editor = wp_get_image_editor($fileinfo['filepath_original']);
369
- if (is_wp_error($editor)) {
370
- echo $prefix_ko . $fileinfo['basename'] . " (wp_get_image_editor): " . $editor->get_error_message();
 
371
  continue;
372
  }
373
 
374
- if ($webimg['resize']) {
375
  $editor->set_quality($webimg['quality']);
376
 
377
  $resized = $editor->resize($webimg['width'], $webimg['height'], $webimg['crop']);
378
- if (is_wp_error($resized)) {
379
- echo $prefix_ko . $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->webimage({$webimg['width']}, {$webimg['height']}, {$webimg['crop']})): " . $resized->get_error_message() . $eol;
 
380
  continue;
381
  }
382
 
383
  $saved = $editor->save($fileinfo['filepath']);
384
- if (is_wp_error($saved)) {
385
- echo $prefix_ko . $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->webimage): " . $saved->get_error_message() . $eol;
 
386
  continue;
387
  }
388
  }
@@ -391,26 +601,29 @@ function gmedia_images_update($files)
391
  $editor->set_quality($thumbimg['quality']);
392
 
393
  $resized = $editor->resize($thumbimg['width'], $thumbimg['height'], $thumbimg['crop']);
394
- if (is_wp_error($resized)) {
395
- echo $prefix_ko . $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->thumb({$thumbimg['width']}, {$thumbimg['height']}, {$thumbimg['crop']})): " . $resized->get_error_message() . $eol;
 
396
  continue;
397
  }
398
 
399
  $saved = $editor->save($fileinfo['filepath_thumb']);
400
- if (is_wp_error($saved)) {
401
- echo $prefix_ko . $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->thumb): " . $saved->get_error_message() . $eol;
 
402
  continue;
403
  }
404
  } else {
405
  copy($fileinfo['filepath'], $fileinfo['filepath_thumb']);
406
  }
407
  } else {
408
- //echo $prefix_ko . $fileinfo['basename']. ": " . __("Could not read image size.", 'grand-media') . $eol;
409
- echo $prefix . $fileinfo['basename'] . ": " . __("Ignored", 'grand-media') . $eol;
410
  continue;
411
  }
412
  } else {
413
- echo $prefix_ko . $fileinfo['basename'] . ": " . __("Invalid image.", 'grand-media') . $eol;
 
414
  continue;
415
  }
416
 
@@ -418,29 +631,28 @@ function gmedia_images_update($files)
418
  // Save the data
419
  $gmDB->update_metadata($meta_type = 'gmedia', $id, $meta_key = '_metadata', $gmDB->generate_gmedia_metadata($id, $fileinfo));
420
 
421
- echo $prefix . $fileinfo['basename'] . ': <span style="color:darkgreen;">' . sprintf(__('success (ID #%s)', 'grand-media'), $id) . '</span>' . $eol;
 
422
  }
423
 
424
- echo '<p>' . __('Image update process complete...', 'grand-media') . '</p>';
 
425
 
426
- wp_ob_end_flush_all();
427
  }
428
 
429
- function gmedia_flush_rewrite_rules()
430
- {
431
  flush_rewrite_rules(false);
432
  }
433
 
434
- function gmedia_restore_original_images()
435
- {
436
  global $wpdb, $gmGallery, $gmCore, $gmDB;
437
 
438
  $fix_files = glob($gmCore->upload['path'] . '/' . $gmGallery->options['folder']['image_original'] . '/?*.?*_backup', GLOB_NOSORT);
439
- if (! empty($fix_files)) {
440
- foreach ($fix_files as $ff) {
441
  $gmuid = basename($ff, '_backup');
442
  $id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->prefix}gmedia WHERE gmuid = %s", $gmuid));
443
- if ($id) {
444
  $gmDB->update_metadata('gmedia', $id, '_modified', 1);
445
  @rename($ff, $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['image_original'] . '/' . $gmuid);
446
  } else {
@@ -451,19 +663,18 @@ function gmedia_restore_original_images()
451
  }
452
 
453
 
454
- function gmedia_quite_update()
455
- {
456
  global $wpdb, $gmDB, $gmCore, $gmGallery;
457
  $current_version = get_option('gmediaVersion', null);
458
  //$current_db_version = get_option( 'gmediaDbVersion', null );
459
- if ((null !== $current_version)) {
460
  $options = get_option('gmediaOptions');
461
- if (! is_array($options)) {
462
  $options = array();
463
  }
464
  require_once(dirname(__FILE__) . '/setup.php');
465
- $default_options = gmedia_default_options();
466
- if (! get_option('gmediaInstallDate')) {
467
  $date = $wpdb->get_var("SELECT {$wpdb->prefix}gmedia.date FROM {$wpdb->prefix}gmedia ORDER BY ID ASC");
468
  if(!$date) {
469
  $date = '1 month ago';
@@ -472,12 +683,12 @@ function gmedia_quite_update()
472
  add_option('gmediaInstallDate', $installDate);
473
  }
474
 
475
- if (version_compare($current_version, '0.9.23', '<')) {
476
- if (isset($options['license_name'])) {
477
  $default_options['license_name'] = $options['license_name'];
478
  $default_options['license_key'] = $options['license_key'];
479
  $default_options['license_key2'] = $options['license_key2'];
480
- } elseif (isset($options['product_name'])) {
481
  $default_options['license_name'] = $options['product_name'];
482
  $default_options['license_key'] = $options['gmedia_key'];
483
  $default_options['license_key2'] = $options['gmedia_key2'];
@@ -489,26 +700,26 @@ function gmedia_quite_update()
489
  update_option('gmediaOptions', $gmGallery->options);
490
  }
491
 
492
- if (version_compare($current_version, '1.2.0', '<')) {
493
  gmedia_capabilities();
494
  }
495
 
496
- if (version_compare($current_version, '1.4.4', '<')) {
497
- if (! get_option('GmediaHashID_salt')) {
498
  $ustr = wp_generate_password(12, false);
499
  add_option('GmediaHashID_salt', $ustr);
500
  }
501
  }
502
 
503
- if (version_compare($current_version, '1.6.01', '<')) {
504
  $gmDB->set_capability('administrator', 'gmedia_filter_manage');
505
  }
506
 
507
- if (version_compare($current_version, '1.6.3', '<')) {
508
  $wpdb->update($wpdb->prefix . 'gmedia_meta', array('meta_key' => '_cover'), array('meta_key' => 'cover'));
509
  $wpdb->update($wpdb->prefix . 'gmedia_meta', array('meta_key' => '_rating'), array('meta_key' => 'rating'));
510
  }
511
- if (version_compare($current_version, '1.6.5', '<')) {
512
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_edited'), array('meta_key' => 'edited'));
513
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_settings'), array('meta_key' => 'settings'));
514
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_query'), array('meta_key' => 'query'));
@@ -516,22 +727,28 @@ function gmedia_quite_update()
516
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_order'), array('meta_key' => 'order'));
517
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_orderby'), array('meta_key' => 'orderby'));
518
  }
519
- if (version_compare($current_version, '1.6.6', '<')) {
520
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'ID'), array('meta_key' => '_orderby', 'meta_value' => ''));
521
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'DESC'), array('meta_key' => '_order', 'meta_value' => ''));
522
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'title'), array('meta_key' => '_orderby', 'meta_value' => 'title ID'));
523
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'date'), array('meta_key' => '_orderby', 'meta_value' => 'date ID'));
524
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'modified'), array('meta_key' => '_orderby', 'meta_value' => 'modified ID'));
525
  }
526
- if (version_compare($current_version, '1.7.1', '<')) {
527
  $gmedia_ids = $gmDB->get_gmedias(array('mime_type' => 'audio', 'fields' => 'ids'));
528
- foreach ($gmedia_ids as $id) {
529
  $gmDB->update_metadata($meta_type = 'gmedia', $id, $meta_key = '_metadata', $gmDB->generate_gmedia_metadata($id));
530
  }
531
  }
532
- if (version_compare($current_version, '1.7.20', '<')) {
533
  gmedia_restore_original_images();
534
  }
 
 
 
 
 
 
535
 
536
  $gmCore->delete_folder($gmCore->upload['path'] . '/module/afflux');
537
  $gmCore->delete_folder($gmCore->upload['path'] . '/module/jq-mplayer');
@@ -540,5 +757,7 @@ function gmedia_quite_update()
540
  $gmCore->delete_folder($gmCore->upload['path'] . '/module/wp-videoplayer');
541
 
542
  update_option("gmediaVersion", GMEDIA_VERSION);
 
 
543
  }
544
  }
3
  * Update Gmedia plugin
4
  */
5
 
6
+ function gmedia_upgrade_required_admin_notice() {
 
7
  ?>
8
  <div id="message" class="updated gmedia-message">
9
+ <p><?php _e('<strong>GmediaGallery Database Update Required</strong> &#8211; We need to update your install to the latest version.', 'grand-media'); ?></p>
10
 
11
+ <p><?php _e('<strong>Important:</strong> &#8211; It is strongly recommended that you backup your database before proceeding.', 'grand-media'); ?></p>
12
 
13
  <p><?php _e('The update process may take a little while, so please be patient.', 'grand-media'); ?></p>
14
 
17
  </p>
18
  </div>
19
  <script type="text/javascript">
20
+ jQuery('.gm-update-now').click('click', function() {
21
+ return confirm('<?php _e('It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'grand-media'); ?>');
22
  });
23
  </script>
24
  <?php
25
 
26
  }
27
 
28
+ function gmedia_upgrade_process_admin_notice() {
 
29
  ?>
30
  <div id="message" class="updated gmedia-message">
31
+ <p><?php _e('<strong>GmediaGallery Database Update Required</strong> &#8211; We need to update your install to the latest version.', 'grand-media'); ?></p>
 
32
  <p><?php _e('The update process may take a little while, so please be patient.', 'grand-media'); ?></p>
33
  </div>
34
  <?php
35
 
36
  }
37
 
38
+ function gmedia_upgrade_progress_panel() {
39
+ gmedia_do_update();
40
+ ?>
41
+ <div id="gmediaUpdate" class="panel panel-default">
42
+ <div class="panel-body">
43
+ <div id="gmUpdateProgress">
44
+
45
+ </div>
46
+ <div class="gm_upgrade_busy"><img src="<?php echo plugin_dir_url(dirname(__FILE__)) . 'admin/assets/img/loading.gif' ?>" alt="updating..."/></div>
47
+ </div>
48
+ <script type="text/javascript">
49
+ jQuery(function() {
50
+ gmUpdateProgress();
51
+ });
52
+ function gmUpdateProgress() {
53
+ jQuery.ajax({
54
+ type: "get",
55
+ dataType: "json",
56
+ url: ajaxurl,
57
+ data: {action: 'gmedia_upgrade_process'}
58
+ }).done(function(data) {
59
+ if(data.content) {
60
+ jQuery('#gmUpdateProgress').html(data.content);
61
+ }
62
+ if(data.status == 'done') {
63
+ jQuery('.gm_upgrade_busy').remove();
64
+ if('' == data.content) {
65
+ jQuery('#gmUpdateProgress').append('<p><a class="btn btn-success" href="<?php echo admin_url('admin.php?page=GrandMedia'); ?>"><?php _e('Go to Gmedia Library', 'grand-media') ?></a></p>');
66
+ }
67
+ return;
68
+ } else {
69
+ setTimeout(function() { gmUpdateProgress(); }, 2000);
70
+ }
71
+ });
72
+ }
73
+ </script>
74
+ </div>
75
+ <?php
76
+ }
77
 
78
+ function gmedia_do_update() {
79
+ global $wpdb;
80
 
81
+ $info = get_transient('gmediaHeavyJob');
82
+
83
+ @ignore_user_abort(true);
84
+ @set_time_limit(0);
85
+ @ini_set('max_execution_time', 0);
86
 
87
  // upgrade function changed in WordPress 2.3
88
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
90
  // add charset & collate like wp core
91
  $charset_collate = '';
92
 
93
+ if($wpdb->has_cap('collation')) {
94
+ if(!empty($wpdb->charset)) {
95
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
96
  }
97
+ if(!empty($wpdb->collate)) {
98
  $charset_collate .= " COLLATE $wpdb->collate";
99
  }
100
  }
114
  link VARCHAR(255) NOT NULL DEFAULT '',
115
  modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
116
  mime_type VARCHAR(100) NOT NULL DEFAULT '',
117
+ status VARCHAR(20) NOT NULL DEFAULT 'publish',
118
+ post_id BIGINT(20) UNSIGNED DEFAULT NULL,
119
  PRIMARY KEY (ID),
120
  KEY gmuid (gmuid),
121
  KEY type_status_date (mime_type,status,date,ID),
122
+ KEY author (author),
123
+ KEY post_id (post_id)
124
  ) {$charset_collate};
125
  CREATE TABLE {$gmedia_term} (
126
  term_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
129
  description LONGTEXT NOT NULL,
130
  global BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
131
  count BIGINT(20) NOT NULL DEFAULT '0',
132
+ status VARCHAR(20) NOT NULL DEFAULT 'publish',
133
  PRIMARY KEY (term_id),
134
  KEY taxonomy (taxonomy),
135
  KEY name (name)
145
  ";
146
  dbDelta($sql);
147
 
148
+ if(!$info) {
149
+ $info = array();
150
+ }
151
+ $info['db_tables'] = __('Gmedia database tables updated...', 'grand-media');
152
+ set_transient('gmediaHeavyJob', $info);
153
+
154
+ $upgrading = get_transient('gmediaUpgrade');
155
+ if($upgrading && (time() - $upgrading) > 20) {
156
+ $upgrading = false;
157
+ }
158
+ if((defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) && !$upgrading) {
159
+ set_transient('gmediaUpgrade', time());
160
+ gmedia_db_update();
161
+ } elseif(!wp_get_schedule('gmedia_db_update') && !$upgrading) {
162
+ //delete_transient('gmediaUpgradeSteps');
163
+ set_transient('gmediaUpgrade', time());
164
+ wp_schedule_single_event(time() + 1, 'gmedia_db_update');
165
+ }
166
+
167
  }
168
+
169
+ add_action('gmedia_db_update', 'gmedia_db_update');
170
+ function gmedia_db_update() {
171
+
172
+ @ignore_user_abort(true);
173
+ @set_time_limit(0);
174
+ @ini_set('max_execution_time', 0);
175
+
176
+ $db_version = get_option('gmediaDbVersion');
177
+ $info = get_transient('gmediaHeavyJob');
178
+
179
+ if(version_compare($db_version, '0.9.6', '<')) {
180
+ gmedia_db_update__0_9_6();
181
+
182
+ } elseif(version_compare($db_version, '1.8.0', '<')) {
183
+ gmedia_db_update__1_8_0();
184
+
185
+ } else {
186
+ $info['update_complete'] = __('GmediaGallery plugin update complete.', 'grand-media');
187
+ set_transient('gmediaHeavyJob', $info);
188
+
189
+ gmedia_flush_rewrite_rules();
190
+
191
+ sleep(4);
192
+ delete_transient('gmediaHeavyJob');
193
+ delete_transient('gmediaUpgrade');
194
+ delete_transient('gmediaUpgradeSteps');
195
+ }
196
  }
 
197
 
198
+ function gmedia_db_update__0_9_6() {
199
+ global $wpdb, $gmDB, $gmCore, $gmGallery;
200
 
201
+ $info = get_transient('gmediaHeavyJob');
202
+
203
+ $info['096_1'] = __('Start update images...', 'grand-media');
204
+ set_transient('gmediaHeavyJob', $info);
205
+ set_transient('gmediaUpgrade', time());
206
 
207
  $old_options = get_option('gmediaOptions');
208
  require_once(dirname(__FILE__) . '/setup.php');
209
  $options = gmedia_default_options();
210
+ if(isset($old_options['product_name'])) {
211
  $options['license_name'] = $old_options['product_name'];
212
  $options['license_key'] = $old_options['gmedia_key'];
213
  $options['license_key2'] = $old_options['gmedia_key2'];
216
  $gmGallery->options = $options;
217
 
218
  $fix_files = glob($gmCore->upload['path'] . '/?*.?*', GLOB_NOSORT);
219
+ if(!empty($fix_files)) {
220
+ foreach($fix_files as $ff) {
221
  @rename($ff, $gmCore->upload['path'] . '/image/' . basename($ff));
222
  }
223
  }
224
 
225
  $gmedias = $gmDB->get_gmedias(array('mime_type' => 'image/*', 'cache_results' => false));
226
  $files = array();
227
+ foreach($gmedias as $gmedia) {
228
  $files[] = array(
229
+ 'id' => $gmedia->ID,
230
+ 'file' => $gmCore->upload['path'] . '/image/' . $gmedia->gmuid,
231
  );
232
  }
233
+ if(!empty($files)) {
234
  gmedia_images_update($files);
235
  }
236
  $gmCore->delete_folder($gmCore->upload['path'] . '/link');
237
 
238
  // try to make gallery dirs if not exists
239
+ foreach($gmGallery->options['folder'] as $folder) {
240
  wp_mkdir_p($gmCore->upload['path'] . '/' . $folder);
241
  }
242
 
244
  $wpdb->update($wpdb->prefix . 'gmedia_term', array('taxonomy' => 'gmedia_gallery'), array('taxonomy' => 'gmedia_module'));
245
 
246
  $gmedias = $gmDB->get_gmedias(array('no_found_rows' => true, 'meta_key' => 'link', 'cache_results' => false));
247
+ foreach($gmedias as $gmedia) {
248
  $link = $gmDB->get_metadata('gmedia', $gmedia->ID, 'link', true);
249
+ if($link) {
250
  $wpdb->update($wpdb->prefix . 'gmedia', array('link' => $link), array('ID' => $gmedia->ID));
251
  }
252
  }
253
  $wpdb->delete($wpdb->prefix . 'gmedia_meta', array('meta_key' => 'link'));
 
 
254
  $wpdb->update($wpdb->prefix . 'gmedia_meta', array('meta_key' => '_cover'), array('meta_key' => 'preview'));
255
 
256
+ $info['096_2'] = __('Gmedia database data updated...', 'grand-media');
257
+ set_transient('gmediaHeavyJob', $info);
258
+ set_transient('gmediaUpgrade', time());
259
 
260
  $galleries = $gmDB->get_terms('gmedia_gallery');
261
+ if($galleries) {
262
+ foreach($galleries as $gallery) {
263
  $old_meta = $gmDB->get_metadata('gmedia_term', $gallery->term_id);
264
+ if(!empty($old_meta)) {
265
  $old_meta = array_map('reset', $old_meta);
266
+ if(!isset($old_meta['gMediaQuery'])) {
 
267
  continue;
268
  }
 
 
 
 
 
 
 
269
  $gmedia_category = $gmedia_tag = array();
270
+ foreach($old_meta['gMediaQuery'] as $tab) {
271
+ if(isset($tab['cat']) && !empty($tab['cat'])) {
272
  $gmedia_category[] = $tab['cat'];
273
  }
274
+ if(isset($tab['tag__in']) && !empty($tab['tag__in'])) {
275
  $gmedia_tag = array_merge($gmedia_tag, $tab['tag__in']);
276
  }
277
  }
278
  $query = array();
279
+ if(!empty($gmedia_category)) {
280
  $query = array('gmedia_album' => $gmedia_category);
281
+ } elseif(!empty($gmedia_tag)) {
282
  $query = array('gmedia_tag' => $gmedia_tag);
283
  }
284
  $gallery_meta = array(
285
+ '_edited' => $old_meta['last_edited'],
286
+ '_module' => $old_meta['module_name'],
287
+ '_query' => $query
288
  );
289
+ foreach($gallery_meta as $key => $value) {
290
  $gmDB->update_metadata('gmedia_term', $gallery->term_id, $key, $value);
291
  }
292
  }
293
  }
294
  }
295
 
296
+ update_option("gmediaDbVersion", '0.9.6');
 
297
 
298
+ $info['096_3'] = __('Gmedia Galleries updated...', 'grand-media');
299
+ set_transient('gmediaHeavyJob', $info);
300
+ set_transient('gmediaUpgrade', time());
301
+
302
+ //wp_schedule_single_event(time() + 2, 'gmedia_db_update');
303
+ gmedia_db_update();
304
+ }
305
+
306
+ function gmedia_db_update__1_8_0() {
307
+ global $wpdb, $gmDB, $gmGallery;
308
+
309
+ $info = get_transient('gmediaHeavyJob');
310
+ $steps = get_transient('gmediaUpgradeSteps');
311
+ if(!isset($steps['status_update'])) {
312
+ $wpdb->update($wpdb->prefix . 'gmedia', array('status' => 'publish'), array('status' => 'public'));
313
+ $wpdb->update($wpdb->prefix . 'gmedia_term', array('status' => 'publish'), array('status' => 'public'));
314
+ $wpdb->update($wpdb->prefix . 'gmedia_term', array('global' => 0), array('taxonomy' => 'gmedia_tag'));
315
+ $wpdb->update($wpdb->prefix . 'gmedia_term', array('global' => 0), array('taxonomy' => 'gmedia_category'));
316
+
317
+ $info['180_1'] = __('Gmedia database data updated...', 'grand-media');
318
+ $info['180_2'] = __('Adding ability to comment gmedia items...', 'grand-media');
319
+ set_transient('gmediaHeavyJob', $info);
320
+ $steps['status_update'] = 1;
321
+ $steps['step'] = 0;
322
+ }
323
+
324
+ set_transient('gmediaUpgrade', time());
325
+
326
+ $steps['step']++;
327
+
328
+ if(!isset($steps['gmedia_posts'])) {
329
+ $gm_options = $gmGallery->options;
330
+ $step = $steps['step'];
331
+
332
+ $gmedias = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia WHERE post_id IS NULL OR post_id = '' OR post_id = 0 LIMIT 100");
333
+ if(!empty($gmedias)) {
334
+ $post_data = array(
335
+ 'post_type' => 'gmedia',
336
+ 'comment_status' => $gm_options['default_gmedia_comment_status']
337
+ );
338
+ $total = count($gmedias);
339
+ $i = 0;
340
+ foreach($gmedias as $gmedia) {
341
+ $i++;
342
+
343
+ $post_data['post_author'] = $gmedia->author;
344
+ $post_data['post_content'] = $gmedia->description;
345
+ $post_data['post_title'] = (trim($gmedia->title)? $gmedia->title : $gmedia->gmuid);
346
+ $post_data['post_status'] = $gmedia->status;
347
+ $post_data['post_name'] = $gmedia->gmuid;
348
+ $post_data['post_date'] = $gmedia->date;
349
+ $post_data['post_modified'] = $gmedia->modified;
350
+ $post_data['post_mime_type'] = $gmedia->mime_type;
351
+
352
+ $post_ID = wp_insert_post($post_data);
353
+ if($post_ID) {
354
+ add_metadata('post', $post_ID, '_gmedia_ID', $gmedia->ID);
355
+ $wpdb->update($wpdb->prefix . 'gmedia', array('post_id' => $post_ID), array('ID' => $gmedia->ID));
356
+
357
+ $info['180_3_' . $step] = sprintf(__('Step %d: Updating %d of %d items...', 'grand-media'), $step, $i, $total);
358
+ set_transient('gmediaHeavyJob', $info);
359
+ set_transient('gmediaUpgrade', time());
360
+ }
361
+ }
362
+
363
+ $info['180_4_' . $step] = __('Update cache...', 'grand-media');
364
+ set_transient('gmediaHeavyJob', $info);
365
+
366
+ $gmDB->update_gmedia_caches($gmedias, false, false);
367
+
368
+ set_transient('gmediaUpgradeSteps', $steps);
369
+ if((defined('DISABLE_WP_CRON') && DISABLE_WP_CRON)) {
370
+ set_transient('gmediaUpgrade', time() - 17);
371
+ } else {
372
+ wp_schedule_single_event(time(), 'gmedia_db_update');
373
+ }
374
+ } else {
375
+ $info['180_5'] = __('Adding other features...', 'grand-media');
376
+ set_transient('gmediaHeavyJob', $info);
377
+
378
+ $steps['gmedia_posts'] = 1;
379
+ }
380
+ }
381
+
382
+ if(isset($steps['gmedia_posts']) && !isset($steps['terms_posts'])) {
383
+ $taxonomies = array('gmedia_album', 'gmedia_filter', 'gmedia_gallery');
384
+ $gmedia_terms_with_post = $wpdb->get_col("SELECT gmedia_term_id FROM {$wpdb->prefix}gmedia_term_meta WHERE meta_key = '_post_ID' AND meta_value != ''");
385
+ $gmedia_terms_exclude = '';
386
+ if(!empty($gmedia_terms_with_post)) {
387
+ $gmedia_terms_exclude = "AND term_id NOT IN ('" . implode("','", $gmedia_terms_with_post) . "')";
388
+ }
389
+ $gmedia_terms = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}gmedia_term WHERE taxonomy IN('" . implode("','", $taxonomies) . "') {$gmedia_terms_exclude} LIMIT 100");
390
+ if(!empty($gmedia_terms)) {
391
+ $total = count($gmedia_terms);
392
+ $i = 0;
393
+ foreach($gmedia_terms as $term) {
394
+ if($gmDB->get_metadata('gmedia_term', $term->term_id, '_post_ID', true)) {
395
+ continue;
396
+ }
397
+ $post_data = array(
398
+ 'post_author' => $term->global
399
+ , 'post_content' => $term->description
400
+ , 'post_title' => $term->name
401
+ , 'post_status' => $term->status
402
+ , 'post_type' => $term->taxonomy
403
+ );
404
+ $post_ID = wp_insert_post($post_data);
405
+ if($post_ID) {
406
+ add_metadata('post', $post_ID, '_gmedia_term_ID', $term->term_id);
407
+ $gmDB->add_metadata('gmedia_term', $term->term_id, '_post_ID', $post_ID);
408
+
409
+ $i++;
410
+ $info['180_6_' . $step] = sprintf(__('Step %d: Updating %d of %d items...', 'grand-media'), $step, $i, $total);
411
+ set_transient('gmediaHeavyJob', $info);
412
+ set_transient('gmediaUpgrade', time());
413
+ }
414
+ }
415
+
416
+ set_transient('gmediaUpgradeSteps', $steps);
417
+ if((defined('DISABLE_WP_CRON') && DISABLE_WP_CRON)) {
418
+ set_transient('gmediaUpgrade', time() - 17);
419
+ } else {
420
+ wp_schedule_single_event(time(), 'gmedia_db_update');
421
+ }
422
+ } else {
423
+ $info['180_7'] = __('Update cache...', 'grand-media');
424
+ set_transient('gmediaHeavyJob', $info);
425
+
426
+ foreach($taxonomies as $taxonomy) {
427
+ wp_cache_delete('all_ids', $taxonomy);
428
+ wp_cache_delete('get', $taxonomy);
429
+ }
430
+ wp_cache_set('last_changed', time(), 'gmedia_terms');
431
+ set_transient('gmediaUpgrade', time());
432
+
433
+ $steps['terms_posts'] = 1;
434
+ }
435
+ }
436
+
437
+ if(isset($steps['terms_posts'])) {
438
+ update_option("gmediaDbVersion", '1.8.0');
439
+ set_transient('gmediaUpgradeSteps', $steps);
440
+ //wp_schedule_single_event(time() + 2, 'gmedia_db_update');
441
+ gmedia_db_update();
442
+ }
443
 
 
444
  }
445
 
446
  /**
447
  * @param $files
448
  */
449
+ function gmedia_images_update($files) {
 
450
  global $wpdb, $gmCore, $gmGallery;
451
 
452
+ $info = get_transient('gmediaHeavyJob');
 
 
453
 
454
  $eol = '</pre>' . PHP_EOL;
455
  $c = count($files);
456
  $i = 0;
457
+ foreach($files as $file) {
458
 
459
  /**
460
  * @var $file
461
  * @var $id
462
  */
463
+ if(is_array($file)) {
464
+ if(isset($file['file'])) {
465
  extract($file);
466
  } else {
467
  _e('Something went wrong...', 'grand-media');
469
  }
470
  }
471
 
 
 
472
  $i++;
473
  $prefix = "\n<pre style='display:block;'>$i/$c - ";
474
  $prefix_ko = "\n<pre style='display:block;color:darkred;'>$i/$c - ";
475
 
476
+ if(!is_file($file)) {
477
  $fileinfo = $gmCore->fileinfo($file, false);
478
+ if(is_file($fileinfo['filepath_original'])) {
479
  @rename($fileinfo['filepath_original'], $fileinfo['filepath']);
480
  } else {
481
+ $info['img_' . $i] = $prefix_ko . sprintf(__('File not exists: %s', 'grand-media'), $file) . $eol;
482
+ set_transient('gmediaHeavyJob', $info);
483
  continue;
484
  }
485
  }
487
  $file_File = $file;
488
  $fileinfo = $gmCore->fileinfo($file, false);
489
 
490
+ if($file_File != $fileinfo['filepath']) {
491
  @rename($file_File, $fileinfo['filepath']);
492
  $wpdb->update($wpdb->prefix . 'gmedia', array('gmuid' => $fileinfo['basename']), array('gmuid' => basename($file_File)));
493
  }
494
 
495
+ if('image' == $fileinfo['dirname']) {
496
  $size = @getimagesize($fileinfo['filepath']);
497
+ if(!file_exists($fileinfo['filepath_thumb']) && file_is_displayable_image($fileinfo['filepath'])) {
498
+ if(function_exists('memory_get_usage')) {
499
  $extensions = array('1' => 'GIF', '2' => 'JPG', '3' => 'PNG', '6' => 'BMP');
500
+ switch($extensions[$size[2]]) {
501
  case 'GIF':
502
  $CHANNEL = 1;
503
+ break;
504
  case 'JPG':
505
  $CHANNEL = $size['channels'];
506
+ break;
507
  case 'PNG':
508
  $CHANNEL = 3;
509
+ break;
510
  case 'BMP':
511
  default:
512
  $CHANNEL = 6;
513
+ break;
514
  }
515
  $MB = 1048576; // number of bytes in 1M
516
  $K64 = 65536; // number of bytes in 64K
519
  $memoryNeeded = memory_get_usage() + $memoryNeeded;
520
  $current_limit = @ini_get('memory_limit');
521
  $current_limit_int = intval($current_limit);
522
+ if(false !== strpos($current_limit, 'M')) {
523
  $current_limit_int *= $MB;
524
  }
525
+ if(false !== strpos($current_limit, 'G')) {
526
  $current_limit_int *= 1024;
527
  }
528
 
529
+ if(-1 != $current_limit && $memoryNeeded > $current_limit_int) {
530
  $newLimit = $current_limit_int / $MB + ceil(($memoryNeeded - $current_limit_int) / $MB);
531
  @ini_set('memory_limit', $newLimit . 'M');
532
  }
533
  }
534
 
535
+ if(!wp_mkdir_p($fileinfo['dirpath_thumb'])) {
536
+ $info['img_' . $i] = $prefix_ko . sprintf(__('Unable to create directory `%s`. Is its parent directory writable by the server?', 'grand-media'), $fileinfo['dirpath_thumb']) . $eol;
537
+ set_transient('gmediaHeavyJob', $info);
538
  continue;
539
  }
540
+ if(!is_writable($fileinfo['dirpath_thumb'])) {
541
  @chmod($fileinfo['dirpath_thumb'], 0755);
542
+ if(!is_writable($fileinfo['dirpath_thumb'])) {
543
+ $info['img_' . $i] = $prefix_ko . sprintf(__('Directory `%s` is not writable by the server.', 'grand-media'), $fileinfo['dirpath_thumb']) . $eol;
544
+ set_transient('gmediaHeavyJob', $info);
545
  continue;
546
  }
547
  }
548
+ if(!wp_mkdir_p($fileinfo['dirpath_original'])) {
549
+ $info['img_' . $i] = $prefix_ko . sprintf(__('Unable to create directory `%s`. Is its parent directory writable by the server?', 'grand-media'), $fileinfo['dirpath_original']) . $eol;
550
+ set_transient('gmediaHeavyJob', $info);
551
  continue;
552
  }
553
+ if(!is_writable($fileinfo['dirpath_original'])) {
554
  @chmod($fileinfo['dirpath_original'], 0755);
555
+ if(!is_writable($fileinfo['dirpath_original'])) {
556
+ $info['img_' . $i] = $prefix_ko . sprintf(__('Directory `%s` is not writable by the server.', 'grand-media'), $fileinfo['dirpath_original']) . $eol;
557
+ set_transient('gmediaHeavyJob', $info);
558
  continue;
559
  }
560
  }
563
  $webimg = $gmGallery->options['image'];
564
  $thumbimg = $gmGallery->options['thumb'];
565
 
566
+ $webimg['resize'] = (($webimg['width'] < $size[0]) || ($webimg['height'] < $size[1]))? true : false;
567
+ $thumbimg['resize'] = (($thumbimg['width'] < $size[0]) || ($thumbimg['height'] < $size[1]))? true : false;
568
 
569
+ if($webimg['resize']) {
570
  rename($fileinfo['filepath'], $fileinfo['filepath_original']);
571
  } else {
572
  copy($fileinfo['filepath'], $fileinfo['filepath_original']);
573
  }
574
+ if($webimg['resize'] || $thumbimg['resize']) {
575
  $editor = wp_get_image_editor($fileinfo['filepath_original']);
576
+ if(is_wp_error($editor)) {
577
+ $info['img_' . $i] = $prefix_ko . $fileinfo['basename'] . " (wp_get_image_editor): " . $editor->get_error_message();
578
+ set_transient('gmediaHeavyJob', $info);
579
  continue;
580
  }
581
 
582
+ if($webimg['resize']) {
583
  $editor->set_quality($webimg['quality']);
584
 
585
  $resized = $editor->resize($webimg['width'], $webimg['height'], $webimg['crop']);
586
+ if(is_wp_error($resized)) {
587
+ $info['img_' . $i] = $prefix_ko . $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->webimage({$webimg['width']}, {$webimg['height']}, {$webimg['crop']})): " . $resized->get_error_message() . $eol;
588
+ set_transient('gmediaHeavyJob', $info);
589
  continue;
590
  }
591
 
592
  $saved = $editor->save($fileinfo['filepath']);
593
+ if(is_wp_error($saved)) {
594
+ $info['img_' . $i] = $prefix_ko . $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->webimage): " . $saved->get_error_message() . $eol;
595
+ set_transient('gmediaHeavyJob', $info);
596
  continue;
597
  }
598
  }
601
  $editor->set_quality($thumbimg['quality']);
602
 
603
  $resized = $editor->resize($thumbimg['width'], $thumbimg['height'], $thumbimg['crop']);
604
+ if(is_wp_error($resized)) {
605
+ $info['img_' . $i] = $prefix_ko . $fileinfo['basename'] . " (" . $resized->get_error_code() . " | editor->resize->thumb({$thumbimg['width']}, {$thumbimg['height']}, {$thumbimg['crop']})): " . $resized->get_error_message() . $eol;
606
+ set_transient('gmediaHeavyJob', $info);
607
  continue;
608
  }
609
 
610
  $saved = $editor->save($fileinfo['filepath_thumb']);
611
+ if(is_wp_error($saved)) {
612
+ $info['img_' . $i] = $prefix_ko . $fileinfo['basename'] . " (" . $saved->get_error_code() . " | editor->save->thumb): " . $saved->get_error_message() . $eol;
613
+ set_transient('gmediaHeavyJob', $info);
614
  continue;
615
  }
616
  } else {
617
  copy($fileinfo['filepath'], $fileinfo['filepath_thumb']);
618
  }
619
  } else {
620
+ $info['img_' . $i] = $prefix . $fileinfo['basename'] . ": " . __("Ignored", 'grand-media') . $eol;
621
+ set_transient('gmediaHeavyJob', $info);
622
  continue;
623
  }
624
  } else {
625
+ $info['img_' . $i] = $prefix_ko . $fileinfo['basename'] . ": " . __("Invalid image.", 'grand-media') . $eol;
626
+ set_transient('gmediaHeavyJob', $info);
627
  continue;
628
  }
629
 
631
  // Save the data
632
  $gmDB->update_metadata($meta_type = 'gmedia', $id, $meta_key = '_metadata', $gmDB->generate_gmedia_metadata($id, $fileinfo));
633
 
634
+ $info['img_' . $i] = $prefix . $fileinfo['basename'] . ': <span style="color:darkgreen;">' . sprintf(__('success (ID #%s)', 'grand-media'), $id) . '</span>' . $eol;
635
+ set_transient('gmediaHeavyJob', $info);
636
  }
637
 
638
+ $info['imgs_done'] = '<p>' . __('Image update process complete...', 'grand-media') . '</p>';
639
+ set_transient('gmediaHeavyJob', $info);
640
 
 
641
  }
642
 
643
+ function gmedia_flush_rewrite_rules() {
 
644
  flush_rewrite_rules(false);
645
  }
646
 
647
+ function gmedia_restore_original_images() {
 
648
  global $wpdb, $gmGallery, $gmCore, $gmDB;
649
 
650
  $fix_files = glob($gmCore->upload['path'] . '/' . $gmGallery->options['folder']['image_original'] . '/?*.?*_backup', GLOB_NOSORT);
651
+ if(!empty($fix_files)) {
652
+ foreach($fix_files as $ff) {
653
  $gmuid = basename($ff, '_backup');
654
  $id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->prefix}gmedia WHERE gmuid = %s", $gmuid));
655
+ if($id) {
656
  $gmDB->update_metadata('gmedia', $id, '_modified', 1);
657
  @rename($ff, $gmCore->upload['path'] . '/' . $gmGallery->options['folder']['image_original'] . '/' . $gmuid);
658
  } else {
663
  }
664
 
665
 
666
+ function gmedia_quite_update() {
 
667
  global $wpdb, $gmDB, $gmCore, $gmGallery;
668
  $current_version = get_option('gmediaVersion', null);
669
  //$current_db_version = get_option( 'gmediaDbVersion', null );
670
+ if((null !== $current_version)) {
671
  $options = get_option('gmediaOptions');
672
+ if(!is_array($options)) {
673
  $options = array();
674
  }
675
  require_once(dirname(__FILE__) . '/setup.php');
676
+ $default_options = gmedia_default_options();
677
+ if(!get_option('gmediaInstallDate')) {
678
  $date = $wpdb->get_var("SELECT {$wpdb->prefix}gmedia.date FROM {$wpdb->prefix}gmedia ORDER BY ID ASC");
679
  if(!$date) {
680
  $date = '1 month ago';
683
  add_option('gmediaInstallDate', $installDate);
684
  }
685
 
686
+ if(version_compare($current_version, '0.9.23', '<')) {
687
+ if(isset($options['license_name'])) {
688
  $default_options['license_name'] = $options['license_name'];
689
  $default_options['license_key'] = $options['license_key'];
690
  $default_options['license_key2'] = $options['license_key2'];
691
+ } elseif(isset($options['product_name'])) {
692
  $default_options['license_name'] = $options['product_name'];
693
  $default_options['license_key'] = $options['gmedia_key'];
694
  $default_options['license_key2'] = $options['gmedia_key2'];
700
  update_option('gmediaOptions', $gmGallery->options);
701
  }
702
 
703
+ if(version_compare($current_version, '1.2.0', '<')) {
704
  gmedia_capabilities();
705
  }
706
 
707
+ if(version_compare($current_version, '1.4.4', '<')) {
708
+ if(!get_option('GmediaHashID_salt')) {
709
  $ustr = wp_generate_password(12, false);
710
  add_option('GmediaHashID_salt', $ustr);
711
  }
712
  }
713
 
714
+ if(version_compare($current_version, '1.6.01', '<')) {
715
  $gmDB->set_capability('administrator', 'gmedia_filter_manage');
716
  }
717
 
718
+ if(version_compare($current_version, '1.6.3', '<')) {
719
  $wpdb->update($wpdb->prefix . 'gmedia_meta', array('meta_key' => '_cover'), array('meta_key' => 'cover'));
720
  $wpdb->update($wpdb->prefix . 'gmedia_meta', array('meta_key' => '_rating'), array('meta_key' => 'rating'));
721
  }
722
+ if(version_compare($current_version, '1.6.5', '<')) {
723
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_edited'), array('meta_key' => 'edited'));
724
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_settings'), array('meta_key' => 'settings'));
725
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_query'), array('meta_key' => 'query'));
727
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_order'), array('meta_key' => 'order'));
728
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_key' => '_orderby'), array('meta_key' => 'orderby'));
729
  }
730
+ if(version_compare($current_version, '1.6.6', '<')) {
731
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'ID'), array('meta_key' => '_orderby', 'meta_value' => ''));
732
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'DESC'), array('meta_key' => '_order', 'meta_value' => ''));
733
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'title'), array('meta_key' => '_orderby', 'meta_value' => 'title ID'));
734
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'date'), array('meta_key' => '_orderby', 'meta_value' => 'date ID'));
735
  $wpdb->update($wpdb->prefix . 'gmedia_term_meta', array('meta_value' => 'modified'), array('meta_key' => '_orderby', 'meta_value' => 'modified ID'));
736
  }
737
+ if(version_compare($current_version, '1.7.1', '<')) {
738
  $gmedia_ids = $gmDB->get_gmedias(array('mime_type' => 'audio', 'fields' => 'ids'));
739
+ foreach($gmedia_ids as $id) {
740
  $gmDB->update_metadata($meta_type = 'gmedia', $id, $meta_key = '_metadata', $gmDB->generate_gmedia_metadata($id));
741
  }
742
  }
743
+ if(version_compare($current_version, '1.7.20', '<')) {
744
  gmedia_restore_original_images();
745
  }
746
+ if(version_compare($current_version, '1.8.08', '<')) {
747
+ if(file_exists($gmCore->upload['path'] . '/module/mosaic/js/mosaic.min.js')) {
748
+ @unlink($gmCore->upload['path'] . '/module/mosaic/js/jquery.prettyPhoto-min.js');
749
+ @unlink($gmCore->upload['path'] . '/module/mosaic/js/mosaic.js');
750
+ }
751
+ }
752
 
753
  $gmCore->delete_folder($gmCore->upload['path'] . '/module/afflux');
754
  $gmCore->delete_folder($gmCore->upload['path'] . '/module/jq-mplayer');
757
  $gmCore->delete_folder($gmCore->upload['path'] . '/module/wp-videoplayer');
758
 
759
  update_option("gmediaVersion", GMEDIA_VERSION);
760
+
761
+ $gmCore->app_service('app_updatecron');
762
  }
763
  }
grand-media.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  * Plugin Name: Gmedia Gallery
4
  * Plugin URI: http://wordpress.org/extend/plugins/grand-media/
5
- * Description: Gmedia Gallery - powerfull media library plugin for creating beautiful galleries and managing files.
6
- * Version: 1.7.56
7
  * Author: Rattus
8
  * Author URI: http://codeasily.com/
9
  * Requires at least: 3.6
@@ -42,8 +42,8 @@ if(!class_exists('Gmedia')) {
42
  */
43
  class Gmedia {
44
 
45
- var $version = '1.7.56';
46
- var $dbversion = '0.9.6';
47
  var $minium_WP = '3.6';
48
  var $options = '';
49
  var $do_module = array();
@@ -69,6 +69,7 @@ if(!class_exists('Gmedia')) {
69
  // Load global libraries
70
  require_once(dirname(__FILE__) . '/inc/core.php');
71
  require_once(dirname(__FILE__) . '/inc/db.connect.php');
 
72
 
73
  if($this->options['debug_mode']) {
74
  ini_set('display_errors', true);
@@ -80,6 +81,8 @@ if(!class_exists('Gmedia')) {
80
 
81
  $this->plugin_name = plugin_basename(__FILE__);
82
 
 
 
83
  // Init options & tables during activation & deregister init option
84
  register_activation_hook($this->plugin_name, array(&$this, 'activate'));
85
  register_deactivation_hook($this->plugin_name, array(&$this, 'deactivate'));
@@ -98,6 +101,10 @@ if(!class_exists('Gmedia')) {
98
 
99
  add_action('deleted_user', array(&$this, 'reassign_media'), 10, 2);
100
 
 
 
 
 
101
  //Add some message on the plugins page
102
  //add_action( 'after_plugin_row', array(&$this, 'check_message_version') );
103
  //Add some links on the plugins page
@@ -119,6 +126,11 @@ if(!class_exists('Gmedia')) {
119
  // Load the admin panel or the frontend functions
120
  if(is_admin()) {
121
 
 
 
 
 
 
122
  // Pass the init check or show a message
123
  if(get_option('gmediaInitCheck')) {
124
  add_action('admin_notices', array(&$this, 'admin_notices'));
@@ -131,6 +143,8 @@ if(!class_exists('Gmedia')) {
131
  // Add the script and style files
132
  //add_action('wp_enqueue_scripts', array(&$this, 'load_scripts'), 4);
133
 
 
 
134
  // Add a version number to the header
135
  add_action('wp_head', array(&$this, 'gmedia_head_meta'));
136
  add_action('wp_footer', array(&$this, 'load_module_scripts'));
@@ -144,10 +158,8 @@ if(!class_exists('Gmedia')) {
144
 
145
  function gmedia_head_meta() {
146
  $lk = strtolower($this->options['license_key']);
147
- echo "\n<!-- <meta name='GmediaGallery' version='{$this->version}/{$this->dbversion}' /> -->\n";
148
- if($lk) {
149
- echo "<script type='text/javascript'>var GmediaGallery = {'lk':'{$lk}'}</script>\n";
150
- }
151
  }
152
 
153
  function admin_notices() {
@@ -188,29 +200,52 @@ if(!class_exists('Gmedia')) {
188
  return true;
189
  }
190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  function upgrade() {
192
  // Queue upgrades
193
  $current_version = get_option('gmediaVersion', null);
194
  $current_db_version = get_option('gmediaDbVersion', null);
195
 
196
- require_once(dirname(__FILE__) . '/config/update.php');
197
  if(null === $current_db_version) {
198
  add_option("gmediaDbVersion", GMEDIA_DBVERSION);
199
  } elseif(version_compare($current_db_version, GMEDIA_DBVERSION, '<')) {
200
- if(isset($_GET['do_update']) && ('gmedia' == $_GET['do_update'])) {
201
- add_action('admin_notices', 'gmedia_wait_admin_notice');
 
 
202
  } else {
203
- add_action('admin_notices', 'gmedia_update_admin_notice');
204
  }
205
  }
206
 
207
  if(null === $current_version) {
 
 
208
  add_option("gmediaVersion", GMEDIA_VERSION);
209
  add_action('init', 'gmedia_flush_rewrite_rules', 1000);
210
  } elseif(version_compare($current_version, GMEDIA_VERSION, '<')) {
 
 
211
  gmedia_quite_update();
212
  add_action('init', 'gmedia_flush_rewrite_rules', 1000);
 
 
 
 
213
  }
 
214
  }
215
 
216
  function define_tables() {
@@ -234,14 +269,18 @@ if(!class_exists('Gmedia')) {
234
  }
235
 
236
  function load_options() {
 
237
  // Load the options
238
- $this->options = get_option('gmediaOptions');
 
 
 
 
 
239
  }
240
 
241
  function load_dependencies() {
242
 
243
- require_once(dirname(__FILE__) . '/inc/permalinks.php');
244
-
245
  // We didn't need all stuff during a AJAX operation
246
  if(defined('DOING_AJAX')) {
247
  require_once(dirname(__FILE__) . '/admin/ajax.php');
@@ -281,17 +320,16 @@ if(!class_exists('Gmedia')) {
281
  function register_scripts_backend() {
282
  global $gmCore;
283
 
284
- wp_register_script('gmedia-global-backend', $gmCore->gmedia_url . '/admin/js/gmedia.global.js', array('jquery'), '1.7.0');
285
- wp_localize_script('gmedia-global-backend', 'gmediaGlobalVar', array(
286
- 'ajaxurl' => admin_url('admin-ajax.php'),
287
- 'nonce' => wp_create_nonce('grandMedia'),
288
- 'loading' => $gmCore->gmedia_url . '/admin/img/throbber.gif',
289
- 'uploadPath' => $gmCore->upload['url'],
290
- 'pluginPath' => $gmCore->gmedia_url
291
  ));
292
 
293
- wp_register_style('grand-media', $gmCore->gmedia_url . '/admin/css/gmedia.admin.css', array(), '1.7.54', 'all');
294
- wp_register_script('grand-media', $gmCore->gmedia_url . '/admin/js/gmedia.admin.js', array('jquery', 'gmedia-global-backend'), '1.7.54');
295
  wp_localize_script('grand-media', 'grandMedia', array(
296
  'error3' => __('Disable your Popup Blocker and try again.', 'grand-media'),
297
  'download' => __('downloading...', 'grand-media'),
@@ -309,12 +347,14 @@ if(!class_exists('Gmedia')) {
309
  function register_scripts_frontend() {
310
  global $gmCore, $wp_scripts;
311
 
312
- wp_register_script('gmedia-global-frontend', $gmCore->gmedia_url . '/assets/gmedia.global.front.js', array('jquery'), '0.9.6');
313
- wp_localize_script('gmedia-global-frontend', 'gmediaGlobalVar', array(
314
- 'ajaxurl' => admin_url('admin-ajax.php'),
315
- 'uploadPath' => $gmCore->upload['url'],
316
- 'gmediaKey' => strtolower($this->options['license_key']),
317
- 'mash' => $this->options['license_key2']
 
 
318
  ));
319
 
320
 
@@ -323,17 +363,26 @@ if(!class_exists('Gmedia')) {
323
  wp_register_script('mediaelement', $gmCore->gmedia_url . '/assets/mediaelement/mediaelement-and-player.min.js', array('jquery'), '2.13.0', true);
324
  }
325
 
326
- wp_deregister_style('photoswipe');
327
- wp_deregister_script('photoswipe');
328
- wp_register_style('photoswipe', $gmCore->gmedia_url . '/assets/photoswipe/photoswipe.css', array(), '3.0.5', 'screen');
329
- wp_register_script('photoswipe', $gmCore->gmedia_url . '/assets/photoswipe/photoswipe.jquery.min.js', array('jquery'), '3.0.5', true);
 
 
 
 
 
 
 
 
 
330
 
331
  if(!wp_script_is('easing', 'registered') || version_compare($wp_scripts->registered['easing']->ver, '1.3.0', '<')) {
332
  wp_deregister_script('easing');
333
  wp_register_script('easing', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.easing.js', array('jquery'), '1.3.0', true);
334
  }
335
  if(!wp_script_is('fancybox', 'registered') || version_compare($wp_scripts->registered['fancybox']->ver, '1.3.4', '<')) {
336
- if(!defined('FANCYBOX_VERSION')){
337
  wp_deregister_style('fancybox');
338
  wp_register_style('fancybox', $gmCore->gmedia_url . '/assets/fancybox/jquery.fancybox-1.3.4.css', array(), '1.3.4');
339
  }
@@ -455,9 +504,6 @@ if(!class_exists('Gmedia')) {
455
  */
456
  function activate($networkwide) {
457
  $this->network_propagate('gmedia_install', $networkwide);
458
-
459
- require_once(dirname(__FILE__) . '/inc/permalinks.php');
460
- flush_rewrite_rules(false);
461
  }
462
 
463
  /**
@@ -465,7 +511,11 @@ if(!class_exists('Gmedia')) {
465
  */
466
  function deactivate($networkwide) {
467
  $this->network_propagate('gmedia_deactivate', $networkwide);
468
- flush_rewrite_rules(false);
 
 
 
 
469
  }
470
 
471
  /*
@@ -501,6 +551,101 @@ if(!class_exists('Gmedia')) {
501
  $gmDB->reassign_media($user_id, $reassign);
502
  }
503
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  /*
505
  // PLUGIN MESSAGE ON PLUGINS PAGE
506
  function check_message_version($file)
2
  /*
3
  * Plugin Name: Gmedia Gallery
4
  * Plugin URI: http://wordpress.org/extend/plugins/grand-media/
5
+ * Description: Gmedia Gallery - powerful media library plugin for creating beautiful galleries and managing files.
6
+ * Version: 1.8.10
7
  * Author: Rattus
8
  * Author URI: http://codeasily.com/
9
  * Requires at least: 3.6
42
  */
43
  class Gmedia {
44
 
45
+ var $version = '1.8.10';
46
+ var $dbversion = '1.8.0';
47
  var $minium_WP = '3.6';
48
  var $options = '';
49
  var $do_module = array();
69
  // Load global libraries
70
  require_once(dirname(__FILE__) . '/inc/core.php');
71
  require_once(dirname(__FILE__) . '/inc/db.connect.php');
72
+ require_once(dirname(__FILE__) . '/inc/permalinks.php');
73
 
74
  if($this->options['debug_mode']) {
75
  ini_set('display_errors', true);
81
 
82
  $this->plugin_name = plugin_basename(__FILE__);
83
 
84
+ add_filter('cron_schedules', array(&$this, 'gmedia_cron_schedules'));
85
+
86
  // Init options & tables during activation & deregister init option
87
  register_activation_hook($this->plugin_name, array(&$this, 'activate'));
88
  register_deactivation_hook($this->plugin_name, array(&$this, 'deactivate'));
101
 
102
  add_action('deleted_user', array(&$this, 'reassign_media'), 10, 2);
103
 
104
+ add_action('init', array(&$this, 'gmedia_post_type'), 0);
105
+
106
+ add_action('gmedia_app_cronjob', array(&$this, 'gmedia_app_cronjob'));
107
+
108
  //Add some message on the plugins page
109
  //add_action( 'after_plugin_row', array(&$this, 'check_message_version') );
110
  //Add some links on the plugins page
126
  // Load the admin panel or the frontend functions
127
  if(is_admin()) {
128
 
129
+ // Pass the init check or show a message
130
+ if(get_option('gmediaActivated')) {
131
+ add_action('init', array(&$this, 'gmedia_after_activation'));
132
+ }
133
+
134
  // Pass the init check or show a message
135
  if(get_option('gmediaInitCheck')) {
136
  add_action('admin_notices', array(&$this, 'admin_notices'));
143
  // Add the script and style files
144
  //add_action('wp_enqueue_scripts', array(&$this, 'load_scripts'), 4);
145
 
146
+ require_once(dirname(__FILE__) . '/inc/frontend.filters.php');
147
+
148
  // Add a version number to the header
149
  add_action('wp_head', array(&$this, 'gmedia_head_meta'));
150
  add_action('wp_footer', array(&$this, 'load_module_scripts'));
158
 
159
  function gmedia_head_meta() {
160
  $lk = strtolower($this->options['license_key']);
161
+ $db_version = get_option('gmediaDbVersion');
162
+ echo "\n<!-- <meta name='GmediaGallery' version='{$this->version}/{$db_version}' license='{$lk}' /> -->\n";
 
 
163
  }
164
 
165
  function admin_notices() {
200
  return true;
201
  }
202
 
203
+ /**
204
+ * Called via Setup and register_activate hook after gmedia_install() function
205
+ */
206
+ function gmedia_after_activation() {
207
+ global $gmCore;
208
+
209
+ delete_option('gmediaActivated');
210
+
211
+ flush_rewrite_rules(false);
212
+
213
+ $gmCore->app_service('app_activateplugin');
214
+ }
215
+
216
  function upgrade() {
217
  // Queue upgrades
218
  $current_version = get_option('gmediaVersion', null);
219
  $current_db_version = get_option('gmediaDbVersion', null);
220
 
 
221
  if(null === $current_db_version) {
222
  add_option("gmediaDbVersion", GMEDIA_DBVERSION);
223
  } elseif(version_compare($current_db_version, GMEDIA_DBVERSION, '<')) {
224
+ require_once(dirname(__FILE__) . '/config/update.php');
225
+
226
+ if(get_transient('gmediaUpgrade') || (isset($_GET['do_update']) && ('gmedia' == $_GET['do_update']))) {
227
+ add_action('admin_notices', 'gmedia_upgrade_process_admin_notice');
228
  } else {
229
+ add_action('admin_notices', 'gmedia_upgrade_required_admin_notice');
230
  }
231
  }
232
 
233
  if(null === $current_version) {
234
+ require_once(dirname(__FILE__) . '/config/update.php');
235
+
236
  add_option("gmediaVersion", GMEDIA_VERSION);
237
  add_action('init', 'gmedia_flush_rewrite_rules', 1000);
238
  } elseif(version_compare($current_version, GMEDIA_VERSION, '<')) {
239
+ require_once(dirname(__FILE__) . '/config/update.php');
240
+
241
  gmedia_quite_update();
242
  add_action('init', 'gmedia_flush_rewrite_rules', 1000);
243
+
244
+ if(!wp_get_schedule('gmedia_app_cronjob')) {
245
+ wp_schedule_event(time(), 'gmedia_app', 'gmedia_app_cronjob');
246
+ }
247
  }
248
+
249
  }
250
 
251
  function define_tables() {
269
  }
270
 
271
  function load_options() {
272
+ include_once(dirname(__FILE__) . '/config/setup.php');
273
  // Load the options
274
+ $default_options = gmedia_default_options();
275
+ $db_options = get_option('gmediaOptions');
276
+ if(!is_array($db_options)){
277
+ $db_options = array();
278
+ }
279
+ $this->options = array_merge($default_options, $db_options);
280
  }
281
 
282
  function load_dependencies() {
283
 
 
 
284
  // We didn't need all stuff during a AJAX operation
285
  if(defined('DOING_AJAX')) {
286
  require_once(dirname(__FILE__) . '/admin/ajax.php');
320
  function register_scripts_backend() {
321
  global $gmCore;
322
 
323
+ wp_register_script('gmedia-global-backend', $gmCore->gmedia_url . '/admin/assets/js/gmedia.global.js', array('jquery'), '1.8.0');
324
+ wp_localize_script('gmedia-global-backend', 'GmediaGallery', array(
325
+ 'ajaxurl' => admin_url('admin-ajax.php'),
326
+ 'nonce' => wp_create_nonce('GmediaGallery'),
327
+ 'upload_dirurl' => $gmCore->upload['url'],
328
+ 'plugin_dirurl' => $gmCore->gmedia_url
 
329
  ));
330
 
331
+ wp_register_style('grand-media', $gmCore->gmedia_url . '/admin/assets/css/gmedia.admin.css', array(), '1.8.10', 'all');
332
+ wp_register_script('grand-media', $gmCore->gmedia_url . '/admin/assets/js/gmedia.admin.js', array('jquery', 'gmedia-global-backend'), '1.8.10');
333
  wp_localize_script('grand-media', 'grandMedia', array(
334
  'error3' => __('Disable your Popup Blocker and try again.', 'grand-media'),
335
  'download' => __('downloading...', 'grand-media'),
347
  function register_scripts_frontend() {
348
  global $gmCore, $wp_scripts;
349
 
350
+ wp_register_script('gmedia-global-frontend', $gmCore->gmedia_url . '/assets/gmedia.global.front.js', array('jquery'), '1.8.0');
351
+ wp_localize_script('gmedia-global-frontend', 'GmediaGallery', array(
352
+ 'ajaxurl' => admin_url('admin-ajax.php'),
353
+ 'nonce' => wp_create_nonce('GmediaGallery'),
354
+ 'upload_dirurl' => $gmCore->upload['url'],
355
+ 'plugin_dirurl' => $gmCore->upload['url'],
356
+ 'license' => strtolower($this->options['license_key']),
357
+ 'license2' => $this->options['license_key2']
358
  ));
359
 
360
 
363
  wp_register_script('mediaelement', $gmCore->gmedia_url . '/assets/mediaelement/mediaelement-and-player.min.js', array('jquery'), '2.13.0', true);
364
  }
365
 
366
+ if(!wp_script_is('magnific-popup', 'registered') || version_compare($wp_scripts->registered['magnific-popup']->ver, '1.0.2', '<')) {
367
+ wp_deregister_style('magnific-popup');
368
+ wp_deregister_script('magnific-popup');
369
+ wp_register_style('magnific-popup', $gmCore->gmedia_url . '/assets/mag-popup/magnific-popup.css', array(), '1.0.2', 'screen');
370
+ wp_register_script('magnific-popup', $gmCore->gmedia_url . '/assets/mag-popup/jquery.magnific-popup.min.js', array('jquery'), '1.0.2', true);
371
+ }
372
+
373
+ if(!wp_script_is('photoswipe', 'registered') || version_compare($wp_scripts->registered['photoswipe']->ver, '3.0.5', '<=')) {
374
+ wp_deregister_style('photoswipe');
375
+ wp_deregister_script('photoswipe');
376
+ wp_register_style('photoswipe', $gmCore->gmedia_url . '/assets/photoswipe/photoswipe.css', array(), '3.0.5', 'screen');
377
+ wp_register_script('photoswipe', $gmCore->gmedia_url . '/assets/photoswipe/photoswipe.jquery.min.js', array('jquery'), '3.0.5', true);
378
+ }
379
 
380
  if(!wp_script_is('easing', 'registered') || version_compare($wp_scripts->registered['easing']->ver, '1.3.0', '<')) {
381
  wp_deregister_script('easing');
382
  wp_register_script('easing', $gmCore->gmedia_url . '/assets/jq-plugins/jquery.easing.js', array('jquery'), '1.3.0', true);
383
  }
384
  if(!wp_script_is('fancybox', 'registered') || version_compare($wp_scripts->registered['fancybox']->ver, '1.3.4', '<')) {
385
+ if(!defined('FANCYBOX_VERSION')) {
386
  wp_deregister_style('fancybox');
387
  wp_register_style('fancybox', $gmCore->gmedia_url . '/assets/fancybox/jquery.fancybox-1.3.4.css', array(), '1.3.4');
388
  }
504
  */
505
  function activate($networkwide) {
506
  $this->network_propagate('gmedia_install', $networkwide);
 
 
 
507
  }
508
 
509
  /**
511
  */
512
  function deactivate($networkwide) {
513
  $this->network_propagate('gmedia_deactivate', $networkwide);
514
+ }
515
+
516
+ function gmedia_app_cronjob() {
517
+ global $gmCore;
518
+ $gmCore->app_service('app_updatecron');
519
  }
520
 
521
  /*
551
  $gmDB->reassign_media($user_id, $reassign);
552
  }
553
 
554
+ /**
555
+ * Register Gmedia Post Types
556
+ */
557
+ function gmedia_post_type() {
558
+ $args = array(
559
+ 'label' => __('Gmedia Posts', 'grand-media'),
560
+ 'supports' => array('comments'),
561
+ 'hierarchical' => false,
562
+ 'public' => true,
563
+ 'show_ui' => false,
564
+ 'show_in_menu' => false,
565
+ 'show_in_admin_bar' => true,
566
+ 'show_in_nav_menus' => false,
567
+ 'can_export' => false,
568
+ 'has_archive' => true, //'gmedia-library',
569
+ 'publicly_queryable' => true,
570
+ 'exclude_from_search' => (bool)$this->options['gmedia_exclude_from_search'],
571
+ 'rewrite' => array('slug' => $this->options['gmedia_post_slug'])
572
+ );
573
+ register_post_type('gmedia', $args);
574
+
575
+ $args['label'] = __('Gmedia Custom Filters', 'grand-media');
576
+ $args['exclude_from_search'] = (bool)$this->options['gmedia_filter_exclude_from_search'];
577
+ $args['rewrite'] = array('slug' => $this->options['gmedia_filter_post_slug']);
578
+ register_post_type('gmedia_filter', $args);
579
+
580
+ $args['label'] = __('Gmedia Albums', 'grand-media');
581
+ $args['hierarchical'] = true;
582
+ $args['exclude_from_search'] = (bool)$this->options['gmedia_album_exclude_from_search'];
583
+ $args['rewrite'] = array('slug' => $this->options['gmedia_album_post_slug']);
584
+ register_post_type('gmedia_album', $args);
585
+
586
+ $args['label'] = __('Gmedia Galleries', 'grand-media');
587
+ $args['show_in_nav_menus'] = true;
588
+ $args['exclude_from_search'] = (bool)$this->options['gmedia_gallery_exclude_from_search'];
589
+ $args['rewrite'] = array('slug' => $this->options['gmedia_gallery_post_slug']);
590
+ register_post_type('gmedia_gallery', $args);
591
+
592
+ add_filter('get_edit_post_link', array($this, 'gmedia_post_type_edit_link'), 10, 3);
593
+
594
+ }
595
+
596
+ /**
597
+ * Edit link for gmedia
598
+ *
599
+ * @param $link
600
+ * @param $post_ID
601
+ * @param $context
602
+ *
603
+ * @return string|void
604
+ */
605
+ function gmedia_post_type_edit_link($link, $post_ID, $context) {
606
+ $post = get_post($post_ID);
607
+ if(isset($post->ID) && 'gmedia' == substr($post->post_type, 0, 6)) {
608
+ global $gmDB;
609
+ if($post->post_type == 'gmedia') {
610
+ $gmedia_id = get_post_meta($post->ID, '_gmedia_ID', true);
611
+ $gmedia = $gmDB->get_gmedia($gmedia_id);
612
+ if($gmedia) {
613
+ $link = admin_url("admin.php?page=GrandMedia&edit_mode=1&gmedia__in={$gmedia->ID}");
614
+ } else {
615
+ wp_delete_post($post->ID, true);
616
+ $link = '#';
617
+ }
618
+ } else {
619
+ $term_id = get_post_meta($post->ID, '_gmedia_term_ID', true);
620
+ $gmedia_term = $gmDB->get_term($term_id, $post->post_type);
621
+ if($gmedia_term) {
622
+ if($post->post_type == 'gmedia_album') {
623
+ $link = admin_url("admin.php?page=GrandMedia_Terms&taxonomy={$post->post_type}&edit_item={$gmedia_term->term_id}");
624
+ } elseif($post->post_type == 'gmedia_filter') {
625
+ $link = admin_url("admin.php?page=GrandMedia_Terms&taxonomy={$post->post_type}&edit_item={$gmedia_term->term_id}");
626
+ } elseif($post->post_type == 'gmedia_gallery') {
627
+ $link = admin_url("admin.php?page=GrandMedia_Galleries&edit_item={$gmedia_term->term_id}");
628
+ }
629
+ } else {
630
+ wp_delete_post($post->ID, true);
631
+ $link = '#';
632
+ }
633
+ }
634
+ }
635
+
636
+ return $link;
637
+ }
638
+
639
+
640
+ function gmedia_cron_schedules( $shedules ) {
641
+ $gmedia_shedules = array(
642
+ 'gmedia_app' => array( 'interval' => 5 * DAY_IN_SECONDS, 'display' => __( 'Gmedia App Defined' ) )
643
+ );
644
+ $shedules = array_merge($shedules, $gmedia_shedules);
645
+
646
+ return $shedules;
647
+ }
648
+
649
  /*
650
  // PLUGIN MESSAGE ON PLUGINS PAGE
651
  function check_message_version($file)
inc/core.php CHANGED
@@ -130,7 +130,7 @@ class GmediaCore {
130
  if(true === $uri) {
131
  $uri = admin_url('admin.php');
132
  }
133
- $remove_args = empty($remove_args)? array() : (array) $remove_args;
134
  $remove_args = array_unique(array_merge(array('doing_wp_cron', '_wpnonce', 'delete', 'update_meta'), $remove_args, array_keys($add_args)));
135
  $new_uri = remove_query_arg($remove_args, $uri);
136
  if(!empty($add_args)) {
@@ -247,6 +247,11 @@ class GmediaCore {
247
  if(!is_object($item)) {
248
  $item = $gmDB->get_gmedia($item);
249
  }
 
 
 
 
 
250
  $type = explode('/', $item->mime_type);
251
 
252
  if('image' == $type[0]) {
@@ -271,7 +276,7 @@ class GmediaCore {
271
  if(!$type = wp_ext2type($ext)) {
272
  $type = 'application';
273
  }
274
- $image = $this->gmedia_url . '/admin/img/' . $type . '.png';
275
 
276
  if($cover) {
277
  $cover = $gmDB->get_metadata('gmedia', $item->ID, '_cover', true);
@@ -690,6 +695,23 @@ class GmediaCore {
690
  return $array;
691
  }
692
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
693
 
694
  /**
695
  * @param $photo
@@ -1811,7 +1833,7 @@ class GmediaCore {
1811
  $webimg = $gmGallery->options['image'];
1812
  $thumbimg = $gmGallery->options['thumb'];
1813
 
1814
- $webimg['resize'] = (($webimg['width'] < $size[0]) || ($webimg['height'] < $size[1]))? true : false;
1815
 
1816
  if($webimg['resize']) {
1817
  rename($fileinfo['filepath'], $fileinfo['filepath_original']);
@@ -1819,7 +1841,7 @@ class GmediaCore {
1819
  copy($fileinfo['filepath'], $fileinfo['filepath_original']);
1820
  }
1821
 
1822
- $size_ratio = $size[0]/$size[1];
1823
 
1824
  $angle = 0;
1825
  $image_meta = @$gmCore->wp_read_image_metadata($fileinfo['filepath_original']);
@@ -1829,12 +1851,12 @@ class GmediaCore {
1829
  $angle = 180;
1830
  break;
1831
  case 6:
1832
- $angle = -90;
1833
- $size_ratio = $size[1]/$size[0];
1834
  break;
1835
  case 8:
1836
- $angle = 90;
1837
- $size_ratio = $size[1]/$size[0];
1838
  break;
1839
  }
1840
  }
@@ -1963,7 +1985,7 @@ class GmediaCore {
1963
  if($size) {
1964
  if(!empty($image_meta)) {
1965
  if('exif' == $post_data['set_title']) {
1966
- if(!empty($image_meta['title']) && trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))) {
1967
  $title = $image_meta['title'];
1968
  }
1969
  }
@@ -1978,7 +2000,7 @@ class GmediaCore {
1978
  $file_meta = $this->get_file_metadata($fileinfo['filepath_original'], $fileinfo);
1979
  if(!empty($file_meta)) {
1980
  if('exif' == $post_data['set_title']) {
1981
- if(!empty($file_meta['title']) && trim($file_meta['title']) && !is_numeric(sanitize_title($file_meta['title']))) {
1982
  $title = $file_meta['title'];
1983
  }
1984
  }
@@ -1994,18 +2016,22 @@ class GmediaCore {
1994
  $title = $fileinfo['title'];
1995
  }
1996
 
 
 
 
 
1997
  $status = $post_data['set_status'];
1998
  if('inherit' == $post_data['set_status']) {
1999
  $gmedia_album = isset($post_data['terms']['gmedia_album'])? $post_data['terms']['gmedia_album'] : false;
2000
  if($gmedia_album && $this->is_digit($gmedia_album)) {
2001
  $album = $gmDB->get_term($gmedia_album, 'gmedia_album');
2002
  if(empty($album) || is_wp_error($album)) {
2003
- $status = 'public';
2004
  } else {
2005
  $status = $album->status;
2006
  }
2007
  } else {
2008
- $status = 'public';
2009
  }
2010
  }
2011
 
@@ -2175,13 +2201,13 @@ class GmediaCore {
2175
  if($gmedia_album && $gmCore->is_digit($gmedia_album)) {
2176
  $album = $gmDB->get_term($gmedia_album, 'gmedia_album');
2177
  if(empty($album) || is_wp_error($album)) {
2178
- $_status = 'public';
2179
  } else {
2180
  $_status = $album->status;
2181
  $album_name = $album->name;
2182
  }
2183
  } else {
2184
- $_status = 'public';
2185
  }
2186
 
2187
  $c = count($files);
@@ -2323,7 +2349,7 @@ class GmediaCore {
2323
  $webimg = $gmGallery->options['image'];
2324
  $thumbimg = $gmGallery->options['thumb'];
2325
 
2326
- $webimg['resize'] = (($webimg['width'] < $size[0]) || ($webimg['height'] < $size[1]))? true : false;
2327
 
2328
  if($webimg['resize']) {
2329
  rename($fileinfo['filepath'], $fileinfo['filepath_original']);
@@ -2331,7 +2357,7 @@ class GmediaCore {
2331
  copy($fileinfo['filepath'], $fileinfo['filepath_original']);
2332
  }
2333
 
2334
- $size_ratio = $size[0]/$size[1];
2335
 
2336
  $angle = 0;
2337
  $image_meta = @$gmCore->wp_read_image_metadata($fileinfo['filepath_original']);
@@ -2341,12 +2367,12 @@ class GmediaCore {
2341
  $angle = 180;
2342
  break;
2343
  case 6:
2344
- $angle = -90;
2345
- $size_ratio = $size[1]/$size[0];
2346
  break;
2347
  case 8:
2348
- $angle = 90;
2349
- $size_ratio = $size[1]/$size[0];
2350
  break;
2351
  }
2352
  }
@@ -2515,79 +2541,125 @@ class GmediaCore {
2515
 
2516
  /**
2517
  * @param string $service
2518
- * @param array $data
2519
  *
2520
  * @return array json
2521
  */
2522
- function app_service($service, $data = array()) {
2523
- global $gmProcessor;
2524
 
 
 
 
2525
  if(!current_user_can('manage_options')) {
2526
  die('-1');
2527
  }
2528
- if(!$service || !is_array($data)) {
2529
  die('0');
2530
  }
2531
 
2532
- $result = array();
2533
- $defaults = array('email' => '', 'category' => '');
2534
- $data = array_merge($defaults, $data);
2535
-
2536
- $gm_options = get_option('gmediaOptions');
2537
-
2538
- $gm_options['site_email'] = $data['email'];
2539
- $gm_options['site_category'] = $data['category'];
2540
 
2541
  if($service == 'app_deactivate') {
2542
- $gm_options['mobile_app'] = 0;
2543
  }
2544
 
2545
- if(in_array($service, array('app_activate', 'app_updateinfo')) && !is_email($data['email'])) {
2546
- $result['error'] = $gmProcessor->alert('danger', __('Enter valid email, please', 'grand-media'));
 
2547
  } else {
2548
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2549
  $hash = wp_generate_password('6', false);
2550
 
 
 
 
 
 
 
 
2551
  $data['service'] = $service;
2552
- $data['title'] = get_bloginfo('name');
2553
- $data['description'] = get_bloginfo('description');
2554
- $data['url'] = home_url();
2555
- $data['license'] = $gm_options['license_key'];
2556
- $data['site_ID'] = $gm_options['site_ID'];
2557
  $data['site_hash'] = $hash;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2558
 
2559
  set_transient($hash, $data, 45);
2560
 
2561
- $pgcpost = wp_remote_post('http://mypgc.co/?gmservice=' . $service, array(
 
2562
  'method' => 'POST',
2563
  'timeout' => 45,
2564
- 'body' => array('hash' => $hash, 'url' => $data['url']),
2565
  ));
2566
-
2567
- if(is_wp_error($pgcpost)) {
2568
- $result['error'] = $gmProcessor->alert('danger', $pgcpost->get_error_message());
2569
- }
2570
- $pgcpost_body = wp_remote_retrieve_body($pgcpost);
2571
- $result = (array)json_decode($pgcpost_body);
2572
- if(isset($result['error'])) {
2573
- $result['error'] = $gmProcessor->alert('danger', $result['error']);
 
 
 
 
2574
  } else {
 
 
 
2575
  if(isset($result['message'])) {
2576
- $result['message'] = $gmProcessor->alert('info', $result['message']);
2577
  }
2578
 
2579
  if(isset($result['site_ID'])) {
2580
- $gm_options['site_ID'] = $result['site_ID'];
2581
  }
2582
  if(isset($result['mobile_app'])) {
2583
- $gm_options['mobile_app'] = $result['mobile_app'];
2584
- }
2585
- if(isset($result['site_category'])) {
2586
- $gm_options['site_category'] = $result['site_category'];
2587
  }
2588
  }
 
 
 
 
 
 
 
 
 
2589
  }
2590
- update_option('gmediaOptions', $gm_options);
2591
 
2592
  return $result;
2593
  }
@@ -3112,8 +3184,7 @@ class GmediaCore {
3112
  , 'gmedia_settings'
3113
  );
3114
  }
3115
-
3116
  }
3117
 
3118
  global $gmCore;
3119
- $gmCore = new GmediaCore();
130
  if(true === $uri) {
131
  $uri = admin_url('admin.php');
132
  }
133
+ $remove_args = empty($remove_args)? array() : (array)$remove_args;
134
  $remove_args = array_unique(array_merge(array('doing_wp_cron', '_wpnonce', 'delete', 'update_meta'), $remove_args, array_keys($add_args)));
135
  $new_uri = remove_query_arg($remove_args, $uri);
136
  if(!empty($add_args)) {
247
  if(!is_object($item)) {
248
  $item = $gmDB->get_gmedia($item);
249
  }
250
+ if(empty($item)) {
251
+ $image = $this->gmedia_url . '/admin/assets/img/blank.gif';
252
+
253
+ return $image;
254
+ }
255
  $type = explode('/', $item->mime_type);
256
 
257
  if('image' == $type[0]) {
276
  if(!$type = wp_ext2type($ext)) {
277
  $type = 'application';
278
  }
279
+ $image = $this->gmedia_url . '/admin/assets/img/' . $type . '.png';
280
 
281
  if($cover) {
282
  $cover = $gmDB->get_metadata('gmedia', $item->ID, '_cover', true);
695
  return $array;
696
  }
697
 
698
+ /**
699
+ * @param string $type
700
+ * @param string $content
701
+ *
702
+ * @return string
703
+ */
704
+ public function alert($type = 'info', $content = '') {
705
+ if(empty($content)) {
706
+ return '';
707
+ } elseif(is_array($content)) {
708
+ $content = array_filter($content);
709
+ $content = implode('<br />', $content);
710
+ }
711
+ $alert = '<div class="alert alert-' . $type . ' alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' . $content . '</div>';
712
+
713
+ return $alert;
714
+ }
715
 
716
  /**
717
  * @param $photo
1833
  $webimg = $gmGallery->options['image'];
1834
  $thumbimg = $gmGallery->options['thumb'];
1835
 
1836
+ $webimg['resize'] = (($webimg['width'] < $size[0]) || ($webimg['height'] < $size[1]))? true : false;
1837
 
1838
  if($webimg['resize']) {
1839
  rename($fileinfo['filepath'], $fileinfo['filepath_original']);
1841
  copy($fileinfo['filepath'], $fileinfo['filepath_original']);
1842
  }
1843
 
1844
+ $size_ratio = $size[0] / $size[1];
1845
 
1846
  $angle = 0;
1847
  $image_meta = @$gmCore->wp_read_image_metadata($fileinfo['filepath_original']);
1851
  $angle = 180;
1852
  break;
1853
  case 6:
1854
+ $angle = 270;
1855
+ $size_ratio = $size[1] / $size[0];
1856
  break;
1857
  case 8:
1858
+ $angle = 90;
1859
+ $size_ratio = $size[1] / $size[0];
1860
  break;
1861
  }
1862
  }
1985
  if($size) {
1986
  if(!empty($image_meta)) {
1987
  if('exif' == $post_data['set_title']) {
1988
+ if(!empty($image_meta['title']) && trim($image_meta['title'])) {
1989
  $title = $image_meta['title'];
1990
  }
1991
  }
2000
  $file_meta = $this->get_file_metadata($fileinfo['filepath_original'], $fileinfo);
2001
  if(!empty($file_meta)) {
2002
  if('exif' == $post_data['set_title']) {
2003
+ if(!empty($file_meta['title']) && trim($file_meta['title'])) {
2004
  $title = $file_meta['title'];
2005
  }
2006
  }
2016
  $title = $fileinfo['title'];
2017
  }
2018
 
2019
+ if('public' == $post_data['set_status']) {
2020
+ $post_data['set_status'] = 'publish';
2021
+ }
2022
+
2023
  $status = $post_data['set_status'];
2024
  if('inherit' == $post_data['set_status']) {
2025
  $gmedia_album = isset($post_data['terms']['gmedia_album'])? $post_data['terms']['gmedia_album'] : false;
2026
  if($gmedia_album && $this->is_digit($gmedia_album)) {
2027
  $album = $gmDB->get_term($gmedia_album, 'gmedia_album');
2028
  if(empty($album) || is_wp_error($album)) {
2029
+ $status = 'publish';
2030
  } else {
2031
  $status = $album->status;
2032
  }
2033
  } else {
2034
+ $status = 'publish';
2035
  }
2036
  }
2037
 
2201
  if($gmedia_album && $gmCore->is_digit($gmedia_album)) {
2202
  $album = $gmDB->get_term($gmedia_album, 'gmedia_album');
2203
  if(empty($album) || is_wp_error($album)) {
2204
+ $_status = 'publish';
2205
  } else {
2206
  $_status = $album->status;
2207
  $album_name = $album->name;
2208
  }
2209
  } else {
2210
+ $_status = 'publish';
2211
  }
2212
 
2213
  $c = count($files);
2349
  $webimg = $gmGallery->options['image'];
2350
  $thumbimg = $gmGallery->options['thumb'];
2351
 
2352
+ $webimg['resize'] = (($webimg['width'] < $size[0]) || ($webimg['height'] < $size[1]))? true : false;
2353
 
2354
  if($webimg['resize']) {
2355
  rename($fileinfo['filepath'], $fileinfo['filepath_original']);
2357
  copy($fileinfo['filepath'], $fileinfo['filepath_original']);
2358
  }
2359
 
2360
+ $size_ratio = $size[0] / $size[1];
2361
 
2362
  $angle = 0;
2363
  $image_meta = @$gmCore->wp_read_image_metadata($fileinfo['filepath_original']);
2367
  $angle = 180;
2368
  break;
2369
  case 6:
2370
+ $angle = 270;
2371
+ $size_ratio = $size[1] / $size[0];
2372
  break;
2373
  case 8:
2374
+ $angle = 90;
2375
+ $size_ratio = $size[1] / $size[0];
2376
  break;
2377
  }
2378
  }
2541
 
2542
  /**
2543
  * @param string $service
 
2544
  *
2545
  * @return array json
2546
  */
2547
+ function app_service($service) {
2548
+ global $gmGallery, $gmDB;
2549
 
2550
+ if('127.0.0.1' == $_SERVER['SERVER_ADDR']) {
2551
+ return false;
2552
+ }
2553
  if(!current_user_can('manage_options')) {
2554
  die('-1');
2555
  }
2556
+ if(!$service) {
2557
  die('0');
2558
  }
2559
 
2560
+ $result = array();
2561
+ $data = array();
2562
+ $options = $gmGallery->options;
 
 
 
 
 
2563
 
2564
  if($service == 'app_deactivate') {
2565
+ $options['mobile_app'] = 0;
2566
  }
2567
 
2568
+ $data['site_email'] = $options['site_email'];
2569
+ if(in_array($service, array('app_updateinfo')) && !is_email($data['site_email'])) {
2570
+ $result['error'][] = __('Enter valid email, please', 'grand-media');
2571
  } else {
2572
 
2573
+ $url = home_url();
2574
+ $post_data = array('url' => $url);
2575
+
2576
+ if('app_uninstallplugin' == $service){
2577
+ if(!empty($options['site_ID'])) {
2578
+ $post_data['site_id'] = $options['site_ID'];
2579
+ wp_remote_post('http://gmediaservice.codeasily.com/?gmService=' . $service, array(
2580
+ 'method' => 'POST',
2581
+ 'timeout' => 5,
2582
+ 'body' => $post_data
2583
+ ));
2584
+ }
2585
+ return false;
2586
+ }
2587
+
2588
  $hash = wp_generate_password('6', false);
2589
 
2590
+ if(in_array($service, array('app_activate', 'app_updateinfo'))) {
2591
+ $status = 1;
2592
+ } else {
2593
+ $status = $options['mobile_app'];
2594
+ }
2595
+ $install_date = get_option('gmediaInstallDate');
2596
+
2597
  $data['service'] = $service;
 
 
 
 
 
2598
  $data['site_hash'] = $hash;
2599
+ $data['site_ID'] = $options['site_ID'];
2600
+ $data['title'] = empty($options['site_title'])? get_bloginfo('name') : $options['site_title'];
2601
+ $data['description'] = empty($options['site_description'])? get_bloginfo('description') : $options['site_description'];
2602
+ $data['url'] = $url;
2603
+ $data['license'] = $options['license_key'];
2604
+ $data['status'] = $status;
2605
+ $data['install_date']= $install_date? $install_date : time();
2606
+
2607
+ $tagslist = $gmDB->get_terms('gmedia_tag', array(
2608
+ 'hide_empty' => true,
2609
+ 'fields' => 'names',
2610
+ 'no_found_rows' => true
2611
+ ));
2612
+ if(!is_wp_error($tagslist)) {
2613
+ $data['tags'] = (array)$tagslist;
2614
+ } else {
2615
+ $data['tags'] = array();
2616
+ }
2617
 
2618
  set_transient($hash, $data, 45);
2619
 
2620
+ $post_data['hash'] = $hash;
2621
+ $gms_post = wp_remote_post('http://gmediaservice.codeasily.com/?gmService=' . $service, array(
2622
  'method' => 'POST',
2623
  'timeout' => 45,
2624
+ 'body' => $post_data
2625
  ));
2626
+ if(is_wp_error($gms_post)) {
2627
+ $result['error'][] = $gms_post->get_error_message();
2628
+ }
2629
+ $gms_post_body = wp_remote_retrieve_body($gms_post);
2630
+ $_result = (array)json_decode($gms_post_body);
2631
+ if(isset($_result['error'])) {
2632
+ if(!isset($result['error'])) {
2633
+ $result['error'] = array();
2634
+ }
2635
+ $_result['error'] = (array)$_result['error'];
2636
+ $_result['error'] = array_filter($_result['error'], 'is_string');
2637
+ $result['error'] = array_merge($result['error'], $_result['error']);
2638
  } else {
2639
+ $result = array_merge($_result, $result);
2640
+ //$result['gms_post'] = $gms_post;
2641
+ //$result['gms_post_body'] = $gms_post_body;
2642
  if(isset($result['message'])) {
2643
+ $result['message'] = $this->alert('info', $result['message']);
2644
  }
2645
 
2646
  if(isset($result['site_ID'])) {
2647
+ $options['site_ID'] = $result['site_ID'];
2648
  }
2649
  if(isset($result['mobile_app'])) {
2650
+ $options['mobile_app'] = $result['mobile_app'];
 
 
 
2651
  }
2652
  }
2653
+ if(isset($result['error'])) {
2654
+ $result['error'] = $this->alert('danger', $result['error']);
2655
+ }
2656
+ }
2657
+ update_option('gmediaOptions', $options);
2658
+
2659
+ if(in_array($service, array('app_activate', 'app_updateinfo'))) {
2660
+ wp_clear_scheduled_hook('gmedia_app_cronjob');
2661
+ wp_schedule_event(time(), 'gmedia_app', 'gmedia_app_cronjob');
2662
  }
 
2663
 
2664
  return $result;
2665
  }
3184
  , 'gmedia_settings'
3185
  );
3186
  }
 
3187
  }
3188
 
3189
  global $gmCore;
3190
+ $gmCore = new GmediaCore();
inc/db.connect.php CHANGED
@@ -141,21 +141,19 @@ class GmediaDB {
141
  break;
142
  }
143
  $this->openPage = $gmCore->_get('pager', '1');
144
- $this->resultPerPage = $limit;
145
  if($limit > 0) {
146
- $limit = intval($limit);
147
  $offset = ($this->openPage - 1) * $limit;
148
  $lim = " LIMIT {$offset}, {$limit}";
149
  }
150
  $this->query = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE post_type = 'attachment' {$and} {$search} GROUP BY ID {$ord} {$lim}");
151
- $this->totalResult = $wpdb->get_var("SELECT FOUND_ROWS()");
152
- if(empty($this->totalResult)) {
153
- $this->totalResult = 1;
154
- }
155
- if($limit == 0) {
156
  $limit = $this->totalResult;
 
 
 
157
  }
158
- $this->pages = ceil($this->totalResult / $limit);
159
  if($this->openPage > $this->pages) {
160
  $this->openPage = $this->pages;
161
  if($limit > 0) {
@@ -165,6 +163,7 @@ class GmediaDB {
165
  }
166
  $this->query = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE post_type = 'attachment' {$and} {$search} GROUP BY ID {$ord} {$lim}");
167
  }
 
168
  if(!(empty($search) && empty($and))) {
169
  $this->filter = true;
170
  }
@@ -364,10 +363,10 @@ class GmediaDB {
364
  */
365
  function insert_gmedia($object) {
366
  /** @var $wpdb wpdb */
367
- global $wpdb, $user_ID, $gmCore;
368
 
369
  // TODO media status (vip, password?)
370
- $defaults = array('ID' => false, 'author' => $user_ID, 'modified' => current_time('mysql'));
371
  $object = wp_parse_args($object, $defaults);
372
  if(isset($object['title'])) {
373
  $object['title'] = strip_tags($object['title'], '<span>');
@@ -379,36 +378,29 @@ class GmediaDB {
379
  $object['link'] = esc_url_raw($object['link']);
380
  }
381
  if(!isset($object['status']) || empty($object['status'])) {
382
- $object['status'] = 'public';
383
  }
384
 
385
  // export array as variables
386
  extract($object, EXTR_SKIP);
387
 
388
  // Are we updating or creating?
 
 
389
  if(!empty($ID)) {
390
- $update = true;
391
  $media_ID = (int)$ID;
 
 
 
 
 
392
  } else {
393
- $update = false;
394
- $media_ID = 0;
395
- }
396
-
397
- if(!isset($date) || empty($date)) {
398
- $date = current_time('mysql');
399
- }
400
- if(empty($modified)) {
401
  $modified = $date;
402
  }
403
 
404
- // TODO comment status on each media
405
- /*if ( empty($comment_status) ) {
406
- if ( $update )
407
- $comment_status = 'closed';
408
- else
409
- $comment_status = get_option('default_comment_status');
410
- }*/
411
-
412
  // expected_slashed (everything!)
413
  $data = compact(array('author', 'date', 'description', 'title', 'gmuid', 'modified', 'mime_type', 'link', 'status'));
414
  $data = stripslashes_deep($data);
@@ -420,6 +412,48 @@ class GmediaDB {
420
  $media_ID = (int)$wpdb->insert_id;
421
  }
422
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
  if(isset($terms) && is_array($terms) && count($terms)) {
424
  foreach($terms as $taxonomy => $_terms) {
425
  $taxonomy = trim($taxonomy);
@@ -434,8 +468,10 @@ class GmediaDB {
434
  }
435
  }
436
 
437
- wp_cache_delete($media_ID, 'gmedias');
438
  wp_cache_delete($media_ID, 'gmedia_meta');
 
 
 
439
 
440
  $this->clean_object_term_cache($media_ID);
441
 
@@ -474,20 +510,8 @@ class GmediaDB {
474
  return $gmedia;
475
  }
476
 
477
- //$meta = $this->get_metadata( 'gmedia', $gmedia->ID, '_metadata', true );
478
-
479
  $this->delete_gmedia_term_relationships($gmedia_id, array('gmedia_album', 'gmedia_tag', 'gmedia_category'));
480
 
481
- /* TODO delete object with comments
482
- $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
483
- if ( ! empty( $comment_ids ) ) {
484
- do_action( 'delete_comment', $comment_ids );
485
- foreach ( $comment_ids as $comment_id )
486
- wp_delete_comment( $comment_id, true );
487
- do_action( 'deleted_comment', $comment_ids );
488
- }
489
- */
490
-
491
  $gmedia_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->prefix}gmedia_meta WHERE gmedia_id = %d ", $gmedia_id));
492
  if(!empty($gmedia_meta_ids)) {
493
  do_action('delete_gmedia_meta', $gmedia_meta_ids);
@@ -498,6 +522,9 @@ class GmediaDB {
498
 
499
  do_action('delete_gmedia', $gmedia_id);
500
  $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}gmedia WHERE ID = %d", $gmedia_id));
 
 
 
501
  do_action('deleted_gmedia', $gmedia_id);
502
 
503
 
@@ -543,6 +570,9 @@ class GmediaDB {
543
 
544
  wp_cache_delete($gmedia_id, 'gmedias');
545
  wp_cache_delete($gmedia_id, 'gmedia_meta');
 
 
 
546
  $this->clean_object_term_cache($gmedia_id);
547
 
548
  do_action('clean_gmedia_cache', $gmedia_id);
@@ -625,14 +655,73 @@ class GmediaDB {
625
  } elseif(is_object($media)) {
626
  $_media = $media;
627
  wp_cache_add($media->ID, $_media, 'gmedias');
 
 
 
628
  } else {
629
  $media_id = (int)$media;
630
  if(!$_media = wp_cache_get($media_id, 'gmedias')) {
631
- $_media = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}gmedia WHERE ID = %d LIMIT 1", $media_id));
632
  if(!$_media) {
633
  return $null;
634
  }
635
  wp_cache_add($_media->ID, $_media, 'gmedias');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
  }
637
  }
638
 
@@ -679,9 +768,12 @@ class GmediaDB {
679
  * 'terms_relation' (string) - allows you to describe the boolean relationship between the taxonomy queries.
680
  * Possible values are 'OR', 'AND'.
681
  * 'gmedia_id' (int) - use gmedia id.
 
682
  * 'name' (string) - use gmedia title.
683
  * 'gmedia__in' (array) - use gmedia ids. Specify posts to retrieve.
684
  * 'gmedia__not_in' (array) - use gmedia ids. Specify post NOT to retrieve.
 
 
685
  * 'per_page' (int) - number of post to show per page. Use 'per_page'=>-1 to show all posts.
686
  * 'nopaging' (bool) - show all posts or use pagination. Default value is 'false', use paging.
687
  * 'page' (int) - number of page. Show the posts that would normally show up just on page X.
@@ -696,6 +788,7 @@ class GmediaDB {
696
  * - 'modified' - Order by last modified date.
697
  * - 'rand' - Random order.
698
  * - 'gmedia__in' - Order by 'gmedia__in' parameter. Note: 'gmedia__in' parameter must be specified.
 
699
  * - 'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be
700
  * alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers
701
  * (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).
@@ -719,7 +812,7 @@ class GmediaDB {
719
  * Possible values: 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'.
720
  * Default: 'CHAR'
721
  * 's' (string) - search string or terms separated by comma. Search exactly string if 'exact' parameter set to true
722
- * 'fields' (string) - 'ids': return an array of post IDs.
723
  * 'robots' - bool Default is empty
724
  *
725
  * @see get_posts()
@@ -763,6 +856,7 @@ class GmediaDB {
763
  'tag_id',
764
  'terms_relation',
765
  'gmedia_id',
 
766
  'name',
767
  'page',
768
  'offset',
@@ -794,6 +888,8 @@ class GmediaDB {
794
  'album__not_in',
795
  'gmedia__in',
796
  'gmedia__not_in',
 
 
797
  'tag__in',
798
  'tag__not_in',
799
  'tag__and',
@@ -822,6 +918,7 @@ class GmediaDB {
822
  }
823
 
824
  $q['gmedia_id'] = absint($q['gmedia_id']);
 
825
  $q['year'] = absint($q['year']);
826
  $q['monthnum'] = absint($q['monthnum']);
827
  $q['day'] = absint($q['day']);
@@ -873,8 +970,13 @@ class GmediaDB {
873
  case 'ids':
874
  $fields = "{$wpdb->prefix}gmedia.ID";
875
  break;
 
 
 
876
  default:
877
  $fields = "{$wpdb->prefix}gmedia.*";
 
 
878
  }
879
 
880
  // If a month is specified in the querystring, load that month
@@ -948,6 +1050,23 @@ class GmediaDB {
948
  $where .= " AND {$wpdb->prefix}gmedia.ID NOT IN ($gmedia__not_in)";
949
  }
950
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
951
  // If a search pattern is specified, load the posts that match
952
  if(!empty($q['s'])) {
953
  // added slashes screw with quote grouping when done early, so done later
@@ -1019,7 +1138,7 @@ class GmediaDB {
1019
  $this->gmedias_tag_stuff($q);
1020
 
1021
  if(!empty($q['tag__in'])) {
1022
- $tax_query[] = array(
1023
  'taxonomy' => 'gmedia_tag',
1024
  'terms' => $q['tag__in'],
1025
  'operator' => 'IN'
@@ -1027,7 +1146,7 @@ class GmediaDB {
1027
  }
1028
 
1029
  if(!empty($q['tag__not_in'])) {
1030
- $tax_query[] = array(
1031
  'taxonomy' => 'gmedia_tag',
1032
  'terms' => $q['tag__not_in'],
1033
  'operator' => 'NOT IN'
@@ -1035,7 +1154,7 @@ class GmediaDB {
1035
  }
1036
 
1037
  if(!empty($q['tag__and'])) {
1038
- $tax_query[] = array(
1039
  'taxonomy' => 'gmedia_tag',
1040
  'terms' => $q['tag__and'],
1041
  'operator' => 'AND'
@@ -1095,7 +1214,7 @@ class GmediaDB {
1095
 
1096
  if($album['order'] && ('gmedia_album' == $taxonomy)) {
1097
  $album['alias'] = $alias;
1098
- if('ids' != $q['fields']) {
1099
  $fields .= ", $alias.*";
1100
  }
1101
  }
@@ -1395,19 +1514,18 @@ class GmediaDB {
1395
  }
1396
 
1397
  // Paging
 
 
 
 
1398
  if(empty($q['nopaging'])) {
1399
- $page = absint($q['page']);
1400
- if(empty($page)) {
1401
- $page = 1;
1402
- }
1403
-
1404
- if($q['limit'] && ($q['per_page'] > $q['limit'])){
1405
  $q['per_page'] = $q['limit'];
1406
  }
1407
  if(empty($q['offset']) && ((0 != $q['offset']) || ('0' != $q['offset']))) {
1408
  $per_page = $q['per_page'];
1409
- $offset = ($page - 1) * $per_page;
1410
- if($q['limit'] && (($offset + $per_page) > $q['limit'])){
1411
  $per_page = $q['limit'] - $offset;
1412
  if(0 > $per_page) {
1413
  $per_page = 0;
@@ -1450,28 +1568,33 @@ class GmediaDB {
1450
 
1451
  return $gmedias;
1452
  }
 
 
 
 
 
1453
 
1454
  if(!empty($clauses['where']) || !empty($clauses['whichmimetype'])) {
1455
  $this->filter = true;
1456
  }
1457
 
1458
  $gmedias = $wpdb->get_results($request);
 
1459
 
1460
  if(!$q['no_found_rows'] && !empty($limits)) {
1461
- $this->totalResult = (int) $wpdb->get_var('SELECT FOUND_ROWS()');
1462
- if($q['limit']){
1463
- $this->hardlimit = $q['limit'];
1464
  $this->trueTotalResult = $this->totalResult;
1465
  if($this->totalResult > $q['limit']) {
1466
- $this->totalResult = $q['limit'];
1467
  }
1468
  }
1469
- $this->resultPerPage = $q['per_page'];
1470
  $this->pages = ceil($this->totalResult / $q['per_page']);
1471
- $this->openPage = $page;
1472
  }
1473
 
1474
- $gmedia_count = $this->gmediaCount = count($gmedias);
 
1475
 
1476
  if(!isset($q['cache_results'])) {
1477
  if($_wp_using_ext_object_cache) {
@@ -1689,7 +1812,7 @@ class GmediaDB {
1689
  WHERE taxonomy = 'gmedia_tag'
1690
  AND name IN ({$q['tag_name__in']})
1691
  ");
1692
- if(empty($q['tag_name__in'])){
1693
  $q['tag_name__in_null'] = true;
1694
  }
1695
  }
@@ -1702,7 +1825,7 @@ class GmediaDB {
1702
  WHERE taxonomy = 'gmedia_tag'
1703
  AND name IN ({$q['tag_name__and']})
1704
  ");
1705
- if(empty($q['tag_name__and'])){
1706
  $q['tag_name__and_null'] = true;
1707
  }
1708
  }
@@ -2328,7 +2451,7 @@ class GmediaDB {
2328
  * @return mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
2329
  * exist then WP_Error will be returned.
2330
  */
2331
- function get_term($term, $taxonomy, $output = OBJECT) {
2332
  /** @var $wpdb wpdb */
2333
  global $wpdb, $user_ID, $gmCore;
2334
  $null = null;
@@ -2339,6 +2462,13 @@ class GmediaDB {
2339
  return $error;
2340
  }
2341
 
 
 
 
 
 
 
 
2342
  $gmOptions = get_option('gmediaOptions');
2343
  if(!isset($gmOptions['taxonomies'][$taxonomy])) {
2344
  $error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
@@ -2346,27 +2476,24 @@ class GmediaDB {
2346
  return $error;
2347
  }
2348
 
2349
- if(is_object($term)) {
2350
- $term = $term->term_id;
2351
- }
2352
- if(!$gmCore->is_digit($term)) {
2353
- if($user_ID) {
2354
- $_term = $wpdb->get_row($wpdb->prepare("SELECT t.* FROM {$wpdb->prefix}gmedia_term AS t WHERE t.taxonomy = %s AND t.name = %s AND t.global = %d LIMIT 1", $taxonomy, $term, $user_ID));
2355
  if(!$_term) {
2356
  return $null;
2357
  }
2358
- wp_cache_add($_term->term_id, $_term, $taxonomy);
2359
- } else {
2360
- return $null;
2361
  }
2362
  } else {
2363
- $term = (int)$term;
2364
- if(!$_term = wp_cache_get($term, $taxonomy)) {
2365
- $_term = $wpdb->get_row($wpdb->prepare("SELECT t.* FROM {$wpdb->prefix}gmedia_term AS t WHERE t.taxonomy = %s AND t.term_id = %d LIMIT 1", $taxonomy, $term));
2366
  if(!$_term) {
2367
  return $null;
2368
  }
2369
- wp_cache_add($term, $_term, $taxonomy);
 
 
2370
  }
2371
  }
2372
 
@@ -2469,7 +2596,7 @@ class GmediaDB {
2469
  *
2470
  * offset - The number by which to offset the terms query.
2471
  *
2472
- * status - can be used generaly for albums. Defaults: 'public', 'private', 'draft'.
2473
  *
2474
  * fields - Default is 'all', which returns an array of term objects.
2475
  * If 'fields' is 'ids' or 'names', returns an array of
@@ -2646,7 +2773,7 @@ class GmediaDB {
2646
  $where .= $wpdb->prepare(" AND t.name LIKE %s", $name__like . '%');
2647
  }
2648
 
2649
- if('' !== $global) {
2650
  $global = wp_parse_id_list($global);
2651
  $where .= " AND t.global IN ('" . implode("', '", $global) . "')";
2652
  }
@@ -2656,6 +2783,10 @@ class GmediaDB {
2656
  }
2657
 
2658
  if(!empty($number)) {
 
 
 
 
2659
  if($offset) {
2660
  $limits = 'LIMIT ' . $offset . ',' . $number;
2661
  } else {
@@ -2737,10 +2868,11 @@ class GmediaDB {
2737
  $terms = $wpdb->get_results($query);
2738
  if(!$no_found_rows && !empty($limits)) {
2739
  $this->totalResult = $wpdb->get_var('SELECT FOUND_ROWS()');
2740
- $this->resultPerPage = $number;
2741
  $this->pages = ceil($this->totalResult / $number);
2742
- $this->openPage = $page;
2743
  }
 
 
 
2744
  if(!empty($where)) {
2745
  $this->filter = true;
2746
  }
@@ -2858,7 +2990,7 @@ class GmediaDB {
2858
  return new WP_Error('gm_empty_term_name', __('A name is required for this term'));
2859
  }
2860
 
2861
- $defaults = array('description' => '', 'global' => intval($user_ID), 'status' => 'public');
2862
  $args = wp_parse_args($args, $defaults);
2863
  $args['name'] = $term;
2864
  $args['taxonomy'] = $taxonomy;
@@ -2866,6 +2998,9 @@ class GmediaDB {
2866
  /** @var $name
2867
  * @var $description
2868
  * @var $global
 
 
 
2869
  * @var $meta
2870
  */
2871
  extract($args, EXTR_SKIP);
@@ -2876,19 +3011,24 @@ class GmediaDB {
2876
  $description = maybe_serialize($description);
2877
  } else {
2878
  $description = stripslashes($description);
 
 
 
2879
  }
2880
 
2881
  if(($term_id = $this->term_exists($name, $taxonomy, $global))) {
2882
  // Same name, same global.
2883
  return new WP_Error('gm_term_exists', __('A term with the name provided already exists.'), $term_id);
2884
- } else {
2885
- // This term does not exist, Create it.
2886
- if(false === $wpdb->insert($wpdb->prefix . 'gmedia_term', compact('name', 'taxonomy', 'description', 'global', 'status') + array('count' => 0))) {
2887
- return new WP_Error('gm_db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
2888
- }
2889
- $term_id = (int)$wpdb->insert_id;
2890
  }
2891
 
 
 
 
 
 
 
 
 
2892
  if(isset($meta) && is_array($meta) && !empty($meta)) {
2893
  $meta_type = 'gmedia_term';
2894
  foreach($meta as $key => $value) {
@@ -2904,10 +3044,30 @@ class GmediaDB {
2904
  }
2905
  }
2906
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2907
 
2908
- do_action("create_gmedia_term", $term_id, $taxonomy);
2909
 
2910
- // ? maybe move function to plugin core (refactor!)
2911
  $this->clean_term_cache($term_id, $taxonomy, false);
2912
 
2913
  do_action("created_gmedia_term", $term_id, $taxonomy);
@@ -2934,7 +3094,7 @@ class GmediaDB {
2934
  */
2935
  function update_term($term_id, $taxonomy, $args = array()) {
2936
  /** @var $wpdb wpdb */
2937
- global $wpdb, $gmCore;
2938
 
2939
  $gmOptions = get_option('gmediaOptions');
2940
  if(!isset($gmOptions['taxonomies'][$taxonomy])) {
@@ -2956,13 +3116,11 @@ class GmediaDB {
2956
  // Merge old and new args with new args overwriting old ones.
2957
  $args = array_merge($term, $args);
2958
 
2959
- $defaults = array('global' => $term['global'], 'name' => $term['name'], 'description' => '', 'status' => 'public');
2960
  $args = wp_parse_args($args, $defaults);
2961
 
2962
  /** @var $name
2963
  * @var $description
2964
- * @var $orderby
2965
- * @var $order
2966
  * @var $status
2967
  * @var $global
2968
  * @var $meta
@@ -2971,43 +3129,63 @@ class GmediaDB {
2971
 
2972
  // expected_slashed ($name)
2973
  $name = stripslashes($name);
2974
- if('gmedia_module' == $taxonomy) {
2975
- $description = maybe_serialize($description);
2976
- } else {
2977
- $description = stripslashes($description);
2978
- }
2979
-
2980
  if('' == trim($name)) {
2981
  return new WP_Error('gm_empty_term_name', __('A name is required for term'));
2982
  }
 
2983
  if(current_user_can('gmedia_edit_others_media')) {
2984
  $global = (int)$global;
2985
  } else {
2986
  $global = $term['global'];
2987
  }
2988
 
 
 
 
 
 
 
 
 
 
2989
  $term_id = $wpdb->get_var($wpdb->prepare("SELECT t.term_id FROM {$wpdb->prefix}gmedia_term AS t WHERE t.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id));
2990
  do_action("edit_gmedia_term", $term_id, $taxonomy);
2991
  $wpdb->update($wpdb->prefix . 'gmedia_term', compact('term_id', 'name', 'taxonomy', 'description', 'global', 'status'), array('term_id' => $term_id));
2992
 
2993
- if(('gmedia_album' == $taxonomy) && isset($status_global)) {
2994
- $db_gmedia_ids = $this->get_gmedias(array('no_found_rows' => true, 'album__in' => $term_id, 'fields' => 'ids'));
2995
- if(!empty($db_gmedia_ids)) {
2996
- $values = array();
2997
- foreach($db_gmedia_ids as $gmedia_id) {
2998
- $values[] = $wpdb->prepare("%d", $gmedia_id);
2999
- wp_cache_delete($gmedia_id, 'gmedias');
3000
- }
3001
- if($values) {
3002
- $status = esc_sql($status);
3003
- if(false === $wpdb->query("UPDATE {$wpdb->prefix}gmedia SET status = '{$status}' WHERE ID IN (" . join(',', $values) . ")")) {
3004
- return new WP_Error('db_insert_error', __('Could not update statuses for gmedia items in the database'), $wpdb->last_error);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3005
  }
3006
  }
3007
  }
3008
  }
3009
 
3010
- if(isset($meta) && is_array($meta) && !empty($meta)) {
3011
  $meta_type = 'gmedia_term';
3012
  foreach($meta as $key => $value) {
3013
  if(in_array($key, array('_cover', '_orderby', '_order'))) {
@@ -3030,6 +3208,42 @@ class GmediaDB {
3030
  }
3031
  }
3032
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3033
  do_action("edit_$taxonomy", $term_id);
3034
 
3035
  $term_id = apply_filters('gmedia_term_id_filter', $term_id);
@@ -3070,19 +3284,20 @@ class GmediaDB {
3070
 
3071
  do_action("sort_gmedia_term", $term_id, $taxonomy);
3072
 
3073
- $default_args = array('gmedia_ids' => array(), 'reset_custom_order' => false);
 
 
 
 
3074
  $args = array_merge($default_args, $args);
3075
 
3076
  /** @var $gmedia_ids
3077
  * @var $reset_custom_order
 
3078
  */
3079
  extract($args, EXTR_SKIP);
3080
 
3081
- $default_meta = array(
3082
- '_orderby' => 'ID',
3083
- '_order' => 'DESC'
3084
- );
3085
- $sortorder_meta = array_intersect_key($args['meta'], $default_meta) + $default_meta;
3086
  foreach($sortorder_meta as $key => $value) {
3087
  $this->update_metadata('gmedia_term', $term_id, $key, $value);
3088
  }
@@ -3546,6 +3761,7 @@ class GmediaDB {
3546
  $this->set_gmedia_terms($object, $terms, $taxonomy);
3547
  }
3548
 
 
3549
  $gmedia_term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->prefix}gmedia_term_meta WHERE gmedia_term_id = %d ", $term_id));
3550
  if(!empty($gmedia_term_meta_ids)) {
3551
  do_action('delete_gmedia_term_meta', $gmedia_term_meta_ids);
@@ -3556,6 +3772,9 @@ class GmediaDB {
3556
 
3557
  do_action('delete_gmedia_term', $term_id);
3558
  $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}gmedia_term WHERE term_id = %d", $term_id));
 
 
 
3559
  do_action('deleted_gmedia_term', $term_id);
3560
 
3561
  $this->clean_term_cache($term_id, $taxonomy);
@@ -3643,6 +3862,9 @@ class GmediaDB {
3643
 
3644
  foreach($gmedias as $gmedia) {
3645
  wp_cache_add($gmedia->ID, $gmedia, 'gmedias');
 
 
 
3646
  }
3647
 
3648
  $gmedia_ids = array();
141
  break;
142
  }
143
  $this->openPage = $gmCore->_get('pager', '1');
144
+ $limit = intval($limit);
145
  if($limit > 0) {
 
146
  $offset = ($this->openPage - 1) * $limit;
147
  $lim = " LIMIT {$offset}, {$limit}";
148
  }
149
  $this->query = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE post_type = 'attachment' {$and} {$search} GROUP BY ID {$ord} {$lim}");
150
+ $this->totalResult = (int)$wpdb->get_var("SELECT FOUND_ROWS()");
151
+ if((1 > $limit) || (0 == $this->totalResult)) {
 
 
 
152
  $limit = $this->totalResult;
153
+ $this->pages = 1;
154
+ } else {
155
+ $this->pages = ceil($this->totalResult / $limit);
156
  }
 
157
  if($this->openPage > $this->pages) {
158
  $this->openPage = $this->pages;
159
  if($limit > 0) {
163
  }
164
  $this->query = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE post_type = 'attachment' {$and} {$search} GROUP BY ID {$ord} {$lim}");
165
  }
166
+ $this->resultPerPage = count($this->query);
167
  if(!(empty($search) && empty($and))) {
168
  $this->filter = true;
169
  }
363
  */
364
  function insert_gmedia($object) {
365
  /** @var $wpdb wpdb */
366
+ global $wpdb, $user_ID, $gmCore, $gmGallery;
367
 
368
  // TODO media status (vip, password?)
369
+ $defaults = array('ID' => false, 'author' => $user_ID);
370
  $object = wp_parse_args($object, $defaults);
371
  if(isset($object['title'])) {
372
  $object['title'] = strip_tags($object['title'], '<span>');
378
  $object['link'] = esc_url_raw($object['link']);
379
  }
380
  if(!isset($object['status']) || empty($object['status'])) {
381
+ $object['status'] = 'publish';
382
  }
383
 
384
  // export array as variables
385
  extract($object, EXTR_SKIP);
386
 
387
  // Are we updating or creating?
388
+ $media_ID = 0;
389
+ $update = false;
390
  if(!empty($ID)) {
 
391
  $media_ID = (int)$ID;
392
+ $update = true;
393
+ if(isset($date) && empty($date)) {
394
+ unset($date);
395
+ }
396
+ $modified = current_time('mysql');
397
  } else {
398
+ if(empty($date)) {
399
+ $date = current_time('mysql');
400
+ }
 
 
 
 
 
401
  $modified = $date;
402
  }
403
 
 
 
 
 
 
 
 
 
404
  // expected_slashed (everything!)
405
  $data = compact(array('author', 'date', 'description', 'title', 'gmuid', 'modified', 'mime_type', 'link', 'status'));
406
  $data = stripslashes_deep($data);
412
  $media_ID = (int)$wpdb->insert_id;
413
  }
414
 
415
+ wp_cache_delete($media_ID, 'gmedias');
416
+
417
+ $gmedia = $this->get_gmedia($media_ID);
418
+ $post_ID = $gmedia->post_id;
419
+ $post_data = array(
420
+ 'post_author' => $gmedia->author
421
+ , 'post_content' => $gmedia->description
422
+ , 'post_title' => (trim($gmedia->title)? $gmedia->title : $gmedia->gmuid)
423
+ , 'post_status' => $gmedia->status
424
+ , 'post_type' => 'gmedia'
425
+ , 'post_name' => $gmedia->gmuid
426
+ , 'post_date' => $gmedia->date
427
+ , 'post_modified' => $gmedia->modified
428
+ , 'post_mime_type' => $gmedia->mime_type
429
+ );
430
+
431
+ if(!empty($comment_status)) {
432
+ $post_data['comment_status'] = $comment_status;
433
+ } elseif(!$update) {
434
+ $post_data['comment_status'] = $gmGallery->options['default_gmedia_comment_status'];
435
+ }
436
+
437
+ if(!empty($post_ID)) {
438
+ $post_data['ID'] = $post_ID;
439
+ if(!wp_update_post($post_data)) {
440
+ unset($post_data['ID']);
441
+ $post_ID = wp_insert_post($post_data);
442
+ if($post_ID) {
443
+ add_metadata('post', $post_ID, '_gmedia_ID', $media_ID);
444
+ $wpdb->update($wpdb->prefix . 'gmedia', array('post_id' => $post_ID), array('ID' => $media_ID));
445
+ wp_cache_delete($media_ID, 'gmedias');
446
+ }
447
+ }
448
+ } else {
449
+ $post_ID = wp_insert_post($post_data);
450
+ if($post_ID) {
451
+ add_metadata('post', $post_ID, '_gmedia_ID', $media_ID);
452
+ $wpdb->update($wpdb->prefix . 'gmedia', array('post_id' => $post_ID), array('ID' => $media_ID));
453
+ wp_cache_delete($media_ID, 'gmedias');
454
+ }
455
+ }
456
+
457
  if(isset($terms) && is_array($terms) && count($terms)) {
458
  foreach($terms as $taxonomy => $_terms) {
459
  $taxonomy = trim($taxonomy);
468
  }
469
  }
470
 
 
471
  wp_cache_delete($media_ID, 'gmedia_meta');
472
+ if(!empty($post_ID)) {
473
+ wp_cache_delete($post_ID, 'wpgmedias');
474
+ }
475
 
476
  $this->clean_object_term_cache($media_ID);
477
 
510
  return $gmedia;
511
  }
512
 
 
 
513
  $this->delete_gmedia_term_relationships($gmedia_id, array('gmedia_album', 'gmedia_tag', 'gmedia_category'));
514
 
 
 
 
 
 
 
 
 
 
 
515
  $gmedia_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->prefix}gmedia_meta WHERE gmedia_id = %d ", $gmedia_id));
516
  if(!empty($gmedia_meta_ids)) {
517
  do_action('delete_gmedia_meta', $gmedia_meta_ids);
522
 
523
  do_action('delete_gmedia', $gmedia_id);
524
  $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}gmedia WHERE ID = %d", $gmedia_id));
525
+ if(!empty($gmedia->post_id)) {
526
+ wp_delete_post($gmedia->post_id, true);
527
+ }
528
  do_action('deleted_gmedia', $gmedia_id);
529
 
530
 
570
 
571
  wp_cache_delete($gmedia_id, 'gmedias');
572
  wp_cache_delete($gmedia_id, 'gmedia_meta');
573
+ if(!empty($gmedia->post_id)){
574
+ wp_cache_delete($gmedia->post_id, 'wpgmedias');
575
+ }
576
  $this->clean_object_term_cache($gmedia_id);
577
 
578
  do_action('clean_gmedia_cache', $gmedia_id);
655
  } elseif(is_object($media)) {
656
  $_media = $media;
657
  wp_cache_add($media->ID, $_media, 'gmedias');
658
+ if(!empty($media->post_id)) {
659
+ wp_cache_add($media->post_id, $_media, 'wpgmedias');
660
+ }
661
  } else {
662
  $media_id = (int)$media;
663
  if(!$_media = wp_cache_get($media_id, 'gmedias')) {
664
+ $_media = $wpdb->get_row($wpdb->prepare("SELECT {$wpdb->prefix}gmedia.*, wp.ID as post_id, wp.post_name, wp.post_password, wp.comment_status, wp.comment_count FROM {$wpdb->prefix}gmedia LEFT JOIN {$wpdb->posts} AS wp ON ({$wpdb->prefix}gmedia.post_id = wp.ID) WHERE {$wpdb->prefix}gmedia.ID = %d LIMIT 1", $media_id));
665
  if(!$_media) {
666
  return $null;
667
  }
668
  wp_cache_add($_media->ID, $_media, 'gmedias');
669
+ if(!empty($_media->post_id)){
670
+ wp_cache_add($_media->post_id, $_media, 'wpgmedias');
671
+ }
672
+ }
673
+ }
674
+
675
+ if($output == OBJECT) {
676
+ return $_media;
677
+ } elseif($output == ARRAY_A) {
678
+ $__media = get_object_vars($_media);
679
+
680
+ return $__media;
681
+ } elseif($output == ARRAY_N) {
682
+ $__media = array_values(get_object_vars($_media));
683
+
684
+ return $__media;
685
+ } else {
686
+ return $_media;
687
+ }
688
+ }
689
+
690
+ /**
691
+ * Retrieves gmedia data given a post ID or post object.
692
+ *
693
+ * $post, must be given as a variable, since it is passed by reference.
694
+ *
695
+ * @uses $wpdb
696
+ *
697
+ * @param int|object $post Post ID or gmedia post object.
698
+ * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N.
699
+ *
700
+ * @return mixed Gmedia data
701
+ */
702
+ function get_post_gmedia(&$post, $output = OBJECT) {
703
+ /** @var $wpdb wpdb */
704
+ global $wpdb;
705
+ $null = null;
706
+
707
+ if(empty($post)) {
708
+ return $null;
709
+ }
710
+
711
+ if(is_object($post)) {
712
+ $post_id = $post->ID;
713
+ } else {
714
+ $post_id = (int)$post;
715
+ }
716
+
717
+ if(!$_media = wp_cache_get($post_id, 'wpgmedias')) {
718
+ $_media = $wpdb->get_row($wpdb->prepare("SELECT {$wpdb->prefix}gmedia.*, wp.ID as post_id, wp.post_name, wp.post_password, wp.comment_status, wp.comment_count FROM {$wpdb->prefix}gmedia LEFT JOIN {$wpdb->posts} AS wp ON ({$wpdb->prefix}gmedia.post_id = wp.ID) WHERE {$wpdb->prefix}gmedia.post_id = %d LIMIT 1", $post_id));
719
+ if(!$_media) {
720
+ return $null;
721
+ }
722
+ wp_cache_add($_media->ID, $_media, 'gmedias');
723
+ if(!empty($_media->post_id)){
724
+ wp_cache_add($_media->post_id, $_media, 'wpgmedias');
725
  }
726
  }
727
 
768
  * 'terms_relation' (string) - allows you to describe the boolean relationship between the taxonomy queries.
769
  * Possible values are 'OR', 'AND'.
770
  * 'gmedia_id' (int) - use gmedia id.
771
+ * 'wppost_id' (int) - use gmedia id.
772
  * 'name' (string) - use gmedia title.
773
  * 'gmedia__in' (array) - use gmedia ids. Specify posts to retrieve.
774
  * 'gmedia__not_in' (array) - use gmedia ids. Specify post NOT to retrieve.
775
+ * 'wppost__in' (array) - use gmedia ids. Specify posts to retrieve.
776
+ * 'wppost__not_in' (array) - use gmedia ids. Specify post NOT to retrieve.
777
  * 'per_page' (int) - number of post to show per page. Use 'per_page'=>-1 to show all posts.
778
  * 'nopaging' (bool) - show all posts or use pagination. Default value is 'false', use paging.
779
  * 'page' (int) - number of page. Show the posts that would normally show up just on page X.
788
  * - 'modified' - Order by last modified date.
789
  * - 'rand' - Random order.
790
  * - 'gmedia__in' - Order by 'gmedia__in' parameter. Note: 'gmedia__in' parameter must be specified.
791
+ * - 'wppost__in' - Order by 'wppost__in' parameter. Note: 'wppost__in' parameter must be specified.
792
  * - 'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be
793
  * alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers
794
  * (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).
812
  * Possible values: 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'.
813
  * Default: 'CHAR'
814
  * 's' (string) - search string or terms separated by comma. Search exactly string if 'exact' parameter set to true
815
+ * 'fields' (string) - 'ids': return an array of gmedia IDs; 'post_ids': return an array of gmedia IDs and post_id's
816
  * 'robots' - bool Default is empty
817
  *
818
  * @see get_posts()
856
  'tag_id',
857
  'terms_relation',
858
  'gmedia_id',
859
+ 'wppost_id',
860
  'name',
861
  'page',
862
  'offset',
888
  'album__not_in',
889
  'gmedia__in',
890
  'gmedia__not_in',
891
+ 'wppost__in',
892
+ 'wppost__not_in',
893
  'tag__in',
894
  'tag__not_in',
895
  'tag__and',
918
  }
919
 
920
  $q['gmedia_id'] = absint($q['gmedia_id']);
921
+ $q['wppost_id'] = absint($q['wppost_id']);
922
  $q['year'] = absint($q['year']);
923
  $q['monthnum'] = absint($q['monthnum']);
924
  $q['day'] = absint($q['day']);
970
  case 'ids':
971
  $fields = "{$wpdb->prefix}gmedia.ID";
972
  break;
973
+ case 'post_ids':
974
+ $fields = "{$wpdb->prefix}gmedia.ID, {$wpdb->prefix}gmedia.post_id";
975
+ break;
976
  default:
977
  $fields = "{$wpdb->prefix}gmedia.*";
978
+ $fields .= ", wp.ID as post_id, wp.post_name, wp.post_password, wp.comment_status, wp.comment_count";
979
+ $join .= " LEFT JOIN {$wpdb->posts} AS wp ON ({$wpdb->prefix}gmedia.post_id = wp.ID)";
980
  }
981
 
982
  // If a month is specified in the querystring, load that month
1050
  $where .= " AND {$wpdb->prefix}gmedia.ID NOT IN ($gmedia__not_in)";
1051
  }
1052
 
1053
+ // If a linked wp post number is specified, load that gmedia
1054
+ if($q['wppost_id']) {
1055
+ $where .= " AND {$wpdb->prefix}gmedia.post_id = " . $q['wppost_id'];
1056
+ } elseif($q['wppost__in']) {
1057
+ if(!is_array($q['wppost__in'])) {
1058
+ $q['wppost__in'] = explode(',', $q['wppost__in']);
1059
+ }
1060
+ $wppost__in = implode(',', array_filter(array_map('absint', $q['wppost__in'])));
1061
+ $where .= " AND {$wpdb->prefix}gmedia.post_id IN ($wppost__in)";
1062
+ } elseif($q['wppost__not_in']) {
1063
+ if(!is_array($q['wppost__not_in'])) {
1064
+ $q['wppost__not_in'] = explode(',', $q['wppost__not_in']);
1065
+ }
1066
+ $wppost__not_in = implode(',', array_filter(array_map('absint', $q['wppost__not_in'])));
1067
+ $where .= " AND {$wpdb->prefix}gmedia.post_id NOT IN ($wppost__not_in)";
1068
+ }
1069
+
1070
  // If a search pattern is specified, load the posts that match
1071
  if(!empty($q['s'])) {
1072
  // added slashes screw with quote grouping when done early, so done later
1138
  $this->gmedias_tag_stuff($q);
1139
 
1140
  if(!empty($q['tag__in'])) {
1141
+ $tax_query[] = array(
1142
  'taxonomy' => 'gmedia_tag',
1143
  'terms' => $q['tag__in'],
1144
  'operator' => 'IN'
1146
  }
1147
 
1148
  if(!empty($q['tag__not_in'])) {
1149
+ $tax_query[] = array(
1150
  'taxonomy' => 'gmedia_tag',
1151
  'terms' => $q['tag__not_in'],
1152
  'operator' => 'NOT IN'
1154
  }
1155
 
1156
  if(!empty($q['tag__and'])) {
1157
+ $tax_query[] = array(
1158
  'taxonomy' => 'gmedia_tag',
1159
  'terms' => $q['tag__and'],
1160
  'operator' => 'AND'
1214
 
1215
  if($album['order'] && ('gmedia_album' == $taxonomy)) {
1216
  $album['alias'] = $alias;
1217
+ if('ids' != $q['fields'] || 'post_ids' != $q['fields']) {
1218
  $fields .= ", $alias.*";
1219
  }
1220
  }
1514
  }
1515
 
1516
  // Paging
1517
+ $page = $q['page'];
1518
+ if(empty($page)) {
1519
+ $page = 1;
1520
+ }
1521
  if(empty($q['nopaging'])) {
1522
+ if($q['limit'] && ($q['per_page'] > $q['limit'])) {
 
 
 
 
 
1523
  $q['per_page'] = $q['limit'];
1524
  }
1525
  if(empty($q['offset']) && ((0 != $q['offset']) || ('0' != $q['offset']))) {
1526
  $per_page = $q['per_page'];
1527
+ $offset = ($page - 1) * $per_page;
1528
+ if($q['limit'] && (($offset + $per_page) > $q['limit'])) {
1529
  $per_page = $q['limit'] - $offset;
1530
  if(0 > $per_page) {
1531
  $per_page = 0;
1568
 
1569
  return $gmedias;
1570
  }
1571
+ if('post_ids' == $q['fields']) {
1572
+ $gmedias = $wpdb->get_results($request);
1573
+
1574
+ return $gmedias;
1575
+ }
1576
 
1577
  if(!empty($clauses['where']) || !empty($clauses['whichmimetype'])) {
1578
  $this->filter = true;
1579
  }
1580
 
1581
  $gmedias = $wpdb->get_results($request);
1582
+ $gmedia_count = count($gmedias);
1583
 
1584
  if(!$q['no_found_rows'] && !empty($limits)) {
1585
+ $this->totalResult = (int)$wpdb->get_var('SELECT FOUND_ROWS()');
1586
+ if($q['limit']) {
1587
+ $this->hardlimit = $q['limit'];
1588
  $this->trueTotalResult = $this->totalResult;
1589
  if($this->totalResult > $q['limit']) {
1590
+ $this->totalResult = $q['limit'];
1591
  }
1592
  }
 
1593
  $this->pages = ceil($this->totalResult / $q['per_page']);
 
1594
  }
1595
 
1596
+ $this->openPage = $page;
1597
+ $this->resultPerPage = $gmedia_count;
1598
 
1599
  if(!isset($q['cache_results'])) {
1600
  if($_wp_using_ext_object_cache) {
1812
  WHERE taxonomy = 'gmedia_tag'
1813
  AND name IN ({$q['tag_name__in']})
1814
  ");
1815
+ if(empty($q['tag_name__in'])) {
1816
  $q['tag_name__in_null'] = true;
1817
  }
1818
  }
1825
  WHERE taxonomy = 'gmedia_tag'
1826
  AND name IN ({$q['tag_name__and']})
1827
  ");
1828
+ if(empty($q['tag_name__and'])) {
1829
  $q['tag_name__and_null'] = true;
1830
  }
1831
  }
2451
  * @return mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
2452
  * exist then WP_Error will be returned.
2453
  */
2454
+ function get_term($term, $taxonomy = null, $output = OBJECT) {
2455
  /** @var $wpdb wpdb */
2456
  global $wpdb, $user_ID, $gmCore;
2457
  $null = null;
2462
  return $error;
2463
  }
2464
 
2465
+ if(is_object($term)) {
2466
+ $term = $term->term_id;
2467
+ $taxonomy = $term->taxonomy;
2468
+ } elseif(!$taxonomy){
2469
+ $taxonomy = $this->get_tax_by_term_id($term);
2470
+ }
2471
+
2472
  $gmOptions = get_option('gmediaOptions');
2473
  if(!isset($gmOptions['taxonomies'][$taxonomy])) {
2474
  $error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
2476
  return $error;
2477
  }
2478
 
2479
+ if($gmCore->is_digit($term)) {
2480
+ $term = (int)$term;
2481
+ if(!$_term = wp_cache_get($term, $taxonomy)) {
2482
+ $_term = $wpdb->get_row($wpdb->prepare("SELECT t.* FROM {$wpdb->prefix}gmedia_term AS t WHERE t.taxonomy = %s AND t.term_id = %d LIMIT 1", $taxonomy, $term));
 
 
2483
  if(!$_term) {
2484
  return $null;
2485
  }
2486
+ wp_cache_add($term, $_term, $taxonomy);
 
 
2487
  }
2488
  } else {
2489
+ if($user_ID) {
2490
+ $_term = $wpdb->get_row($wpdb->prepare("SELECT t.* FROM {$wpdb->prefix}gmedia_term AS t WHERE t.taxonomy = %s AND t.name = %s AND t.global = %d LIMIT 1", $taxonomy, $term, $user_ID));
 
2491
  if(!$_term) {
2492
  return $null;
2493
  }
2494
+ wp_cache_add($_term->term_id, $_term, $taxonomy);
2495
+ } else {
2496
+ return $null;
2497
  }
2498
  }
2499
 
2596
  *
2597
  * offset - The number by which to offset the terms query.
2598
  *
2599
+ * status - can be used generaly for albums. Defaults: 'publish', 'private', 'draft'.
2600
  *
2601
  * fields - Default is 'all', which returns an array of term objects.
2602
  * If 'fields' is 'ids' or 'names', returns an array of
2773
  $where .= $wpdb->prepare(" AND t.name LIKE %s", $name__like . '%');
2774
  }
2775
 
2776
+ if(!empty($global) || '0' === $global || 0 === $global) {
2777
  $global = wp_parse_id_list($global);
2778
  $where .= " AND t.global IN ('" . implode("', '", $global) . "')";
2779
  }
2783
  }
2784
 
2785
  if(!empty($number)) {
2786
+ if(!empty($page)){
2787
+ $page = (int)$page? (int)$page : 1;
2788
+ $offset = ($page - 1) * $number;
2789
+ }
2790
  if($offset) {
2791
  $limits = 'LIMIT ' . $offset . ',' . $number;
2792
  } else {
2868
  $terms = $wpdb->get_results($query);
2869
  if(!$no_found_rows && !empty($limits)) {
2870
  $this->totalResult = $wpdb->get_var('SELECT FOUND_ROWS()');
 
2871
  $this->pages = ceil($this->totalResult / $number);
 
2872
  }
2873
+ $this->openPage = $page;
2874
+ $this->resultPerPage = count($terms);
2875
+
2876
  if(!empty($where)) {
2877
  $this->filter = true;
2878
  }
2990
  return new WP_Error('gm_empty_term_name', __('A name is required for this term'));
2991
  }
2992
 
2993
+ $defaults = array('description' => '', 'global' => intval($user_ID), 'status' => 'publish');
2994
  $args = wp_parse_args($args, $defaults);
2995
  $args['name'] = $term;
2996
  $args['taxonomy'] = $taxonomy;
2998
  /** @var $name
2999
  * @var $description
3000
  * @var $global
3001
+ * @var $status
3002
+ * @var $comment_status
3003
+ * @var $slug
3004
  * @var $meta
3005
  */
3006
  extract($args, EXTR_SKIP);
3011
  $description = maybe_serialize($description);
3012
  } else {
3013
  $description = stripslashes($description);
3014
+ if(in_array($taxonomy, array('gmedia_tag', 'gmedia_category'))) {
3015
+ $global = 0;
3016
+ }
3017
  }
3018
 
3019
  if(($term_id = $this->term_exists($name, $taxonomy, $global))) {
3020
  // Same name, same global.
3021
  return new WP_Error('gm_term_exists', __('A term with the name provided already exists.'), $term_id);
 
 
 
 
 
 
3022
  }
3023
 
3024
+ do_action("create_gmedia_term", $term_id, $taxonomy);
3025
+
3026
+ // This term does not exist, Create it.
3027
+ if(false === $wpdb->insert($wpdb->prefix . 'gmedia_term', compact('name', 'taxonomy', 'description', 'global', 'status') + array('count' => 0))) {
3028
+ return new WP_Error('gm_db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
3029
+ }
3030
+ $term_id = (int)$wpdb->insert_id;
3031
+
3032
  if(isset($meta) && is_array($meta) && !empty($meta)) {
3033
  $meta_type = 'gmedia_term';
3034
  foreach($meta as $key => $value) {
3044
  }
3045
  }
3046
 
3047
+ if(in_array($taxonomy, array('gmedia_album', 'gmedia_filter', 'gmedia_gallery'))) {
3048
+ $post_data = array(
3049
+ 'post_author' => $global
3050
+ , 'post_content' => $description
3051
+ , 'post_title' => $name
3052
+ , 'post_status' => $status
3053
+ , 'post_type' => $taxonomy
3054
+ );
3055
+ if(isset($slug) && !empty($slug)) {
3056
+ $post_data['post_name'] = $slug;
3057
+ }
3058
+ if(!empty($comment_status)) {
3059
+ $post_data['comment_status'] = $comment_status;
3060
+ } else {
3061
+ $post_data['comment_status'] = $gmGallery->options['default_gmedia_comment_status'];
3062
+ }
3063
+ $_post_ID = wp_insert_post($post_data);
3064
+ if($_post_ID) {
3065
+ add_metadata('post', $_post_ID, '_gmedia_term_ID', $term_id);
3066
+ $this->add_metadata('gmedia_term', $term_id, '_post_ID', $_post_ID);
3067
+ }
3068
 
3069
+ }
3070
 
 
3071
  $this->clean_term_cache($term_id, $taxonomy, false);
3072
 
3073
  do_action("created_gmedia_term", $term_id, $taxonomy);
3094
  */
3095
  function update_term($term_id, $taxonomy, $args = array()) {
3096
  /** @var $wpdb wpdb */
3097
+ global $wpdb, $gmCore, $gmGallery;
3098
 
3099
  $gmOptions = get_option('gmediaOptions');
3100
  if(!isset($gmOptions['taxonomies'][$taxonomy])) {
3116
  // Merge old and new args with new args overwriting old ones.
3117
  $args = array_merge($term, $args);
3118
 
3119
+ $defaults = array('global' => $term['global'], 'name' => $term['name'], 'description' => '', 'status' => 'publish', 'meta' => array());
3120
  $args = wp_parse_args($args, $defaults);
3121
 
3122
  /** @var $name
3123
  * @var $description
 
 
3124
  * @var $status
3125
  * @var $global
3126
  * @var $meta
3129
 
3130
  // expected_slashed ($name)
3131
  $name = stripslashes($name);
 
 
 
 
 
 
3132
  if('' == trim($name)) {
3133
  return new WP_Error('gm_empty_term_name', __('A name is required for term'));
3134
  }
3135
+
3136
  if(current_user_can('gmedia_edit_others_media')) {
3137
  $global = (int)$global;
3138
  } else {
3139
  $global = $term['global'];
3140
  }
3141
 
3142
+ if('gmedia_module' == $taxonomy) {
3143
+ $description = maybe_serialize($description);
3144
+ } else {
3145
+ $description = stripslashes($description);
3146
+ if(in_array($taxonomy, array('gmedia_tag', 'gmedia_category'))) {
3147
+ $global = 0;
3148
+ }
3149
+ }
3150
+
3151
  $term_id = $wpdb->get_var($wpdb->prepare("SELECT t.term_id FROM {$wpdb->prefix}gmedia_term AS t WHERE t.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id));
3152
  do_action("edit_gmedia_term", $term_id, $taxonomy);
3153
  $wpdb->update($wpdb->prefix . 'gmedia_term', compact('term_id', 'name', 'taxonomy', 'description', 'global', 'status'), array('term_id' => $term_id));
3154
 
3155
+ if(('gmedia_album' == $taxonomy)) {
3156
+ $default_meta = array(
3157
+ '_orderby' => 'ID',
3158
+ '_order' => 'DESC'
3159
+ );
3160
+ $meta = array_merge($default_meta, $meta);
3161
+
3162
+ if(isset($status_global)) {
3163
+ $db_gmedia_ids = $this->get_gmedias(array('no_found_rows' => true, 'album__in' => $term_id, 'fields' => 'post_ids'));
3164
+ if(!empty($db_gmedia_ids)) {
3165
+ $values = array('gm' => array(), 'wp' => array());
3166
+ foreach($db_gmedia_ids as $gmids) {
3167
+ $values['gm'][] = $wpdb->prepare("%d", $gmids->ID);
3168
+ wp_cache_delete($gmids->ID, 'gmedias');
3169
+ if(!empty($gmids->post_id)) {
3170
+ $values['wp'][] = $wpdb->prepare("%d", $gmids->post_id);
3171
+ wp_cache_delete($gmids->post_id, 'wpgmedias');
3172
+ wp_cache_delete($gmids->post_id, 'posts');
3173
+ }
3174
+ }
3175
+ if(!empty($values['gm'])) {
3176
+ $status = esc_sql($status);
3177
+ if(false === $wpdb->query("UPDATE {$wpdb->prefix}gmedia SET status = '{$status}' WHERE ID IN (" . join(',', $values['gm']) . ")")) {
3178
+ return new WP_Error('db_insert_error', __('Could not update statuses for gmedia items in the database'), $wpdb->last_error);
3179
+ }
3180
+ if(!empty($values['wp'])) {
3181
+ $wpdb->query("UPDATE $wpdb->posts SET post_status = '{$status}' WHERE ID IN (" . join(',', $values['wp']) . ")");
3182
+ }
3183
  }
3184
  }
3185
  }
3186
  }
3187
 
3188
+ if(!empty($meta) && is_array($meta)) {
3189
  $meta_type = 'gmedia_term';
3190
  foreach($meta as $key => $value) {
3191
  if(in_array($key, array('_cover', '_orderby', '_order'))) {
3208
  }
3209
  }
3210
 
3211
+ if(in_array($taxonomy, array('gmedia_album', 'gmedia_filter', 'gmedia_gallery'))) {
3212
+ $post_data = array(
3213
+ 'post_author' => $global
3214
+ , 'post_content' => $description
3215
+ , 'post_title' => $name
3216
+ , 'post_status' => $status
3217
+ , 'post_type' => $taxonomy
3218
+ );
3219
+ if(!empty($slug)) {
3220
+ $post_data['post_name'] = $slug;
3221
+ }
3222
+ if(!empty($comment_status)) {
3223
+ $post_data['comment_status'] = $comment_status;
3224
+ } else {
3225
+ $post_data['comment_status'] = $gmGallery->options['default_gmedia_comment_status'];
3226
+ }
3227
+ $_post_ID = $this->get_metadata('gmedia_term', $term_id, '_post_ID', true);
3228
+ if($_post_ID) {
3229
+ $post_data['ID'] = $_post_ID;
3230
+ if(!wp_update_post($post_data)) {
3231
+ unset($post_data['ID']);
3232
+ $_post_ID = wp_insert_post($post_data);
3233
+ if($_post_ID) {
3234
+ add_metadata('post', $_post_ID, '_gmedia_term_ID', $term_id);
3235
+ $this->update_metadata('gmedia_term', $term_id, '_post_ID', $_post_ID);
3236
+ }
3237
+ }
3238
+ } else {
3239
+ $_post_ID = wp_insert_post($post_data);
3240
+ if($_post_ID) {
3241
+ add_metadata('post', $_post_ID, '_gmedia_term_ID', $term_id);
3242
+ $this->update_metadata('gmedia_term', $term_id, '_post_ID', $_post_ID);
3243
+ }
3244
+ }
3245
+ }
3246
+
3247
  do_action("edit_$taxonomy", $term_id);
3248
 
3249
  $term_id = apply_filters('gmedia_term_id_filter', $term_id);
3284
 
3285
  do_action("sort_gmedia_term", $term_id, $taxonomy);
3286
 
3287
+ $default_meta = array(
3288
+ '_orderby' => 'ID',
3289
+ '_order' => 'DESC'
3290
+ );
3291
+ $default_args = array('gmedia_ids' => array(), 'reset_custom_order' => false, 'meta' => $default_meta);
3292
  $args = array_merge($default_args, $args);
3293
 
3294
  /** @var $gmedia_ids
3295
  * @var $reset_custom_order
3296
+ * @var $meta
3297
  */
3298
  extract($args, EXTR_SKIP);
3299
 
3300
+ $sortorder_meta = array_intersect_key($meta, $default_meta) + $default_meta;
 
 
 
 
3301
  foreach($sortorder_meta as $key => $value) {
3302
  $this->update_metadata('gmedia_term', $term_id, $key, $value);
3303
  }
3761
  $this->set_gmedia_terms($object, $terms, $taxonomy);
3762
  }
3763
 
3764
+ $_post_ID = $this->get_metadata('gmedia_term', $term_id, '_post_ID', true);
3765
  $gmedia_term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->prefix}gmedia_term_meta WHERE gmedia_term_id = %d ", $term_id));
3766
  if(!empty($gmedia_term_meta_ids)) {
3767
  do_action('delete_gmedia_term_meta', $gmedia_term_meta_ids);
3772
 
3773
  do_action('delete_gmedia_term', $term_id);
3774
  $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}gmedia_term WHERE term_id = %d", $term_id));
3775
+ if($_post_ID) {
3776
+ wp_delete_post($_post_ID, true);
3777
+ }
3778
  do_action('deleted_gmedia_term', $term_id);
3779
 
3780
  $this->clean_term_cache($term_id, $taxonomy);
3862
 
3863
  foreach($gmedias as $gmedia) {
3864
  wp_cache_add($gmedia->ID, $gmedia, 'gmedias');
3865
+ if(!empty($gmedia->post_id)){
3866
+ wp_cache_add($gmedia->post_id, $gmedia, 'wpgmedias');
3867
+ }
3868
  }
3869
 
3870
  $gmedia_ids = array();
inc/expressInstall.swf CHANGED
File without changes
inc/frontend.filters.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FrontEnd Filters
4
+ */
5
+
6
+ add_action('the_post', 'gmedia_the_post');
7
+ function gmedia_the_post($post) {
8
+ if('gmedia' == substr($post->post_type, 0, 6)) {
9
+ add_filter('get_the_excerpt', 'gmedia_post_type__the_excerpt', 15);
10
+ add_filter('the_content', 'gmedia_post_type__the_content', 20);
11
+ }
12
+ }
13
+ function gmedia_post_type__the_excerpt($content) {
14
+ remove_filter('get_the_excerpt', 'gmedia_post_type__the_excerpt', 15);
15
+ remove_filter('the_content', 'gmedia_post_type__the_content', 20);
16
+ $content = wp_trim_excerpt();
17
+ return gmedia_post_type__the_content($content);
18
+ }
19
+ function gmedia_post_type__the_content($content) {
20
+ global $post, $gmDB, $gmCore;
21
+
22
+ remove_filter('the_content', 'gmedia_post_type__the_content', 20);
23
+ if($post->post_type == 'gmedia') {
24
+ $gmedia_id = get_post_meta($post->ID, '_gmedia_ID', true);
25
+ $gmedia = $gmDB->get_gmedia($gmedia_id);
26
+ if($gmedia) {
27
+ include_once(GMEDIA_ABSPATH . 'admin/pages/library/functions.php');
28
+ gmedia_item_more_data($gmedia);
29
+ if('image' == $gmedia->type) {
30
+ $image_url = $gmCore->gm_get_media_image($gmedia, 'web');
31
+ $content_img = '<a class="gmedia-item-link" href="' . $gmedia->url . '"><img class="gmedia-item" style="max-width:100%;" src="' . $image_url . '" alt="' . esc_attr($gmedia->title) . '"/></a>';
32
+ $content = $content_img . "\n" . $content;
33
+ } else{
34
+ $ext1 = wp_get_audio_extensions();
35
+ $ext2 = wp_get_video_extensions();
36
+ $ext = array_merge($ext1, $ext2);
37
+ if(in_array($gmedia->ext, $ext)) {
38
+ $embed = apply_filters('the_content', "[embed]$gmedia->url[/embed]");
39
+ $content = $embed . "\n" . $content;
40
+ } else {
41
+ $cover_url = $gmCore->gm_get_media_image($gmedia, 'web');
42
+ $content_img = '<a class="gmedia-item-link" href="' . $gmedia->url . '" download="true"><img class="gmedia-item" style="max-width:100%;" src="' . $cover_url . '" alt="' . esc_attr($gmedia->title) . '"/></a>';
43
+ $content = $content_img . "\n" . $content;
44
+ }
45
+ }
46
+ }
47
+ } else {
48
+ if('get_the_excerpt' != current_filter()) {
49
+ $term_id = get_post_meta($post->ID, '_gmedia_term_ID', true);
50
+ if(in_array($post->post_type, array('gmedia_album', 'gmedia_filter'))) {
51
+ $content .= do_shortcode("[gm id={$term_id} module=phantom]");
52
+ } elseif($post->post_type == 'gmedia_gallery') {
53
+ $content .= do_shortcode("[gmedia id={$term_id}]");
54
+ }
55
+ }
56
+ }
57
+
58
+ return $content;
59
+ }
60
+
61
+ /*
62
+ add_filter('the_title', 'gmedia_post_type__the_title', 10, 2);
63
+ function gmedia_post_type__the_title($title, $id = null) {
64
+ if($id && !trim($title)) {
65
+ $post = get_post($id);
66
+ if(isset($post->post_type) && (strpos($post->post_type, 'gmedia') !== false)) {
67
+ global $gmDB;
68
+ if($post->post_type == 'gmedia') {
69
+ $gmedia_id = get_post_meta($post->ID, '_gmedia_ID', true);
70
+ $gmedia = $gmDB->get_gmedia($gmedia_id);
71
+ if($gmedia) {
72
+ $title = trim($gmedia->title)? $gmedia->title : $gmedia->gmuid;
73
+ }
74
+ } else {
75
+ $term_id = get_post_meta($post->ID, '_gmedia_term_ID', true);
76
+ $gmedia_term = $gmDB->get_term($term_id, $post->post_type);
77
+ if($gmedia_term) {
78
+ $title = $gmedia_term->name;
79
+ }
80
+ }
81
+ }
82
+ }
83
+
84
+ return $title;
85
+ }
86
+ */
inc/hashids.php CHANGED
@@ -356,7 +356,11 @@ function gmedia_hash_id_decode($id, $_salt = '', $min_hash_length = 5, $alphabet
356
  if ($return_int) {
357
  $id_arr = $hashid->decode($id);
358
 
359
- return $id_arr[0];
 
 
 
 
360
  } else {
361
  return $hashid->decode($id);
362
  }
356
  if ($return_int) {
357
  $id_arr = $hashid->decode($id);
358
 
359
+ if(is_array($id_arr) && isset($id_arr[0])) {
360
+ return $id_arr[0];
361
+ } else {
362
+ return 0;
363
+ }
364
  } else {
365
  return $hashid->decode($id);
366
  }
inc/media-upload.php CHANGED
@@ -25,7 +25,7 @@ function gmedia_media_buttons_context($context)
25
  {
26
  $button = '
27
  <div style="display:inline-block;">
28
- <a id="gmedia-modal" title="Gmedia Galleries" class="gmedia_button button" href="#gmedia"><span class="wp-media-buttons-icon" style="background: url(' . plugins_url(GMEDIA_FOLDER . '/admin/img/gm-icon.png') . ') no-repeat top left;"></span> ' . __('Gmedia', 'grand-media') . '</a>
29
  </div>';
30
 
31
  return $context . $button;
@@ -191,7 +191,7 @@ function gmedia_add_media_popup_enqueue_scripts()
191
  function gmedia_add_media_galleries()
192
  {
193
 
194
- global $user_ID, $gmCore, $gmDB, $gmGallery, $gmProcessor;
195
 
196
  $post_id = intval($gmCore->_get('post_id'));
197
 
@@ -211,7 +211,7 @@ function gmedia_add_media_galleries()
211
  'number' => $gmCore->_get('number', $per_page),
212
  'hide_empty' => 0,
213
  'page' => $gmCore->_get('pager', 1),
214
- 'status' => array('public', 'private')
215
  );
216
  $args['offset'] = ($args['page'] - 1) * $args['number'];
217
 
@@ -226,7 +226,7 @@ function gmedia_add_media_galleries()
226
  $gmediaTerms = $gmDB->get_terms($taxonomy, $args);
227
  $alert = '';
228
  if (is_wp_error($gmediaTerms)) {
229
- $alert = $gmProcessor->alert('danger', $gmediaTerms->get_error_message());
230
  $gmediaTerms = array();
231
  }
232
 
@@ -457,7 +457,7 @@ function gmedia_add_media_galleries()
457
  function gmedia_add_media_terms()
458
  {
459
 
460
- global $user_ID, $gmCore, $gmDB, $gmGallery, $gmProcessor;
461
 
462
  $post_id = intval($gmCore->_get('post_id'));
463
 
@@ -490,7 +490,7 @@ function gmedia_add_media_terms()
490
 
491
  switch ($taxonomy) {
492
  case 'gmedia_album':
493
- $args['status'] = array('public', 'private');
494
  $args['global'] = $gmCore->_get('author', $gmCore->caps['gmedia_edit_others_media'] ? '' : array(0, $user_ID));
495
  if (! $gmCore->caps['gmedia_show_others_media']) {
496
  $args['global'] = wp_parse_id_list($args['global']);
@@ -524,7 +524,7 @@ function gmedia_add_media_terms()
524
  $gmediaTerms = $gmDB->get_terms($taxonomy, $args);
525
  $alert = '';
526
  if (is_wp_error($gmediaTerms)) {
527
- $alert = $gmProcessor->alert('danger', $gmediaTerms->get_error_message());
528
  $gmediaTerms = array();
529
  }
530
 
@@ -636,7 +636,7 @@ function gmedia_add_media_terms()
636
  $row_class .= ' shared';
637
  $allow_edit = $gmCore->caps['gmedia_edit_others_media'];
638
  }
639
- if ('public' != $item->status) {
640
  $author_name .= ' [' . $item->status . ']';
641
  if ('private' == $item->status) {
642
  $list_row_class = ' list-group-item-info';
@@ -789,12 +789,14 @@ function gmedia_add_media_terms()
789
  <?php if (('gmedia_album' == $taxonomy) && $allow_edit) { ?>
790
  &nbsp; | &nbsp; <a href="<?php echo add_query_arg(array(
791
  'page' => 'GrandMedia_Terms',
792
- 'edit_album' => $item->term_id
 
793
  ), admin_url('admin.php')); ?>" target="_blank"><?php _e('Edit Album', 'grand-media'); ?></a>
794
  <?php } elseif (('gmedia_filter' == $taxonomy) && $allow_edit) { ?>
795
  &nbsp; | &nbsp; <a href="<?php echo add_query_arg(array(
796
  'page' => 'GrandMedia_Terms',
797
- 'edit_filter' => $item->term_id
 
798
  ), admin_url('admin.php')); ?>" target="_blank"><?php _e('Edit Filter', 'grand-media'); ?></a>
799
  <?php } ?>
800
  </p>
@@ -934,7 +936,7 @@ function gmedia_add_media_library()
934
  </div>
935
  <div class="panel-body" id="gm-list-table">
936
  <div class="row">
937
- <div class="col-xs-7 col-md-9" style="text-align:justify;">
938
  <?php
939
  if (count($gmediaQuery)) {
940
  foreach ($gmediaQuery as $item) {
@@ -1253,7 +1255,7 @@ function gmedia_add_media_upload()
1253
  <label><?php _e('Status', 'grand-media'); ?></label>
1254
  <select name="set_status" class="form-control input-sm">
1255
  <option value="inherit"><?php _e('Same as Album or Public', 'grand-media'); ?></option>
1256
- <option value="public"><?php _e('Public', 'grand-media'); ?></option>
1257
  <option value="private"><?php _e('Private', 'grand-media'); ?></option>
1258
  <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
1259
  </select>
@@ -1290,7 +1292,7 @@ function gmedia_add_media_upload()
1290
  $terms_album = '';
1291
  if (count($gm_terms)) {
1292
  foreach ($gm_terms as $term) {
1293
- $terms_album .= '<option value="' . esc_attr($term->term_id) . '">' . esc_html($term->name) . ($term->global ? '' : __(' (shared)', 'grand-media')) . ('public' == $term->status ? '' : " [{$term->status}]") . '</option>' . "\n";
1294
  }
1295
  }
1296
  ?>
25
  {
26
  $button = '
27
  <div style="display:inline-block;">
28
+ <a id="gmedia-modal" title="Gmedia Galleries" class="gmedia_button button" href="#gmedia"><span class="wp-media-buttons-icon" style="background: url(' . plugins_url(GMEDIA_FOLDER . '/admin/assets/img/gm-icon.png') . ') no-repeat top left;"></span> ' . __('Gmedia', 'grand-media') . '</a>
29
  </div>';
30
 
31
  return $context . $button;
191
  function gmedia_add_media_galleries()
192
  {
193
 
194
+ global $user_ID, $gmCore, $gmDB, $gmGallery;
195
 
196
  $post_id = intval($gmCore->_get('post_id'));
197
 
211
  'number' => $gmCore->_get('number', $per_page),
212
  'hide_empty' => 0,
213
  'page' => $gmCore->_get('pager', 1),
214
+ 'status' => array('publish', 'private')
215
  );
216
  $args['offset'] = ($args['page'] - 1) * $args['number'];
217
 
226
  $gmediaTerms = $gmDB->get_terms($taxonomy, $args);
227
  $alert = '';
228
  if (is_wp_error($gmediaTerms)) {
229
+ $alert = $gmCore->alert('danger', $gmediaTerms->get_error_message());
230
  $gmediaTerms = array();
231
  }
232
 
457
  function gmedia_add_media_terms()
458
  {
459
 
460
+ global $user_ID, $gmCore, $gmDB, $gmGallery;
461
 
462
  $post_id = intval($gmCore->_get('post_id'));
463
 
490
 
491
  switch ($taxonomy) {
492
  case 'gmedia_album':
493
+ $args['status'] = array('publish', 'private');
494
  $args['global'] = $gmCore->_get('author', $gmCore->caps['gmedia_edit_others_media'] ? '' : array(0, $user_ID));
495
  if (! $gmCore->caps['gmedia_show_others_media']) {
496
  $args['global'] = wp_parse_id_list($args['global']);
524
  $gmediaTerms = $gmDB->get_terms($taxonomy, $args);
525
  $alert = '';
526
  if (is_wp_error($gmediaTerms)) {
527
+ $alert = $gmCore->alert('danger', $gmediaTerms->get_error_message());
528
  $gmediaTerms = array();
529
  }
530
 
636
  $row_class .= ' shared';
637
  $allow_edit = $gmCore->caps['gmedia_edit_others_media'];
638
  }
639
+ if ('publish' != $item->status) {
640
  $author_name .= ' [' . $item->status . ']';
641
  if ('private' == $item->status) {
642
  $list_row_class = ' list-group-item-info';
789
  <?php if (('gmedia_album' == $taxonomy) && $allow_edit) { ?>
790
  &nbsp; | &nbsp; <a href="<?php echo add_query_arg(array(
791
  'page' => 'GrandMedia_Terms',
792
+ 'taxonomy' => 'gmedia_album',
793
+ 'edit_item' => $item->term_id
794
  ), admin_url('admin.php')); ?>" target="_blank"><?php _e('Edit Album', 'grand-media'); ?></a>
795
  <?php } elseif (('gmedia_filter' == $taxonomy) && $allow_edit) { ?>
796
  &nbsp; | &nbsp; <a href="<?php echo add_query_arg(array(
797
  'page' => 'GrandMedia_Terms',
798
+ 'taxonomy' => 'gmedia_filter',
799
+ 'edit_item' => $item->term_id
800
  ), admin_url('admin.php')); ?>" target="_blank"><?php _e('Edit Filter', 'grand-media'); ?></a>
801
  <?php } ?>
802
  </p>
936
  </div>
937
  <div class="panel-body" id="gm-list-table">
938
  <div class="row">
939
+ <div class="col-xs-7 col-md-9" style="text-align:justify;white-space:normal;">
940
  <?php
941
  if (count($gmediaQuery)) {
942
  foreach ($gmediaQuery as $item) {
1255
  <label><?php _e('Status', 'grand-media'); ?></label>
1256
  <select name="set_status" class="form-control input-sm">
1257
  <option value="inherit"><?php _e('Same as Album or Public', 'grand-media'); ?></option>
1258
+ <option value="publish"><?php _e('Public', 'grand-media'); ?></option>
1259
  <option value="private"><?php _e('Private', 'grand-media'); ?></option>
1260
  <option value="draft"><?php _e('Draft', 'grand-media'); ?></option>
1261
  </select>
1292
  $terms_album = '';
1293
  if (count($gm_terms)) {
1294
  foreach ($gm_terms as $term) {
1295
+ $terms_album .= '<option value="' . esc_attr($term->term_id) . '">' . esc_html($term->name) . ($term->global ? '' : __(' (shared)', 'grand-media')) . ('publish' == $term->status ? '' : " [{$term->status}]") . '</option>' . "\n";
1296
  }
1297
  }
1298
  ?>
inc/permalinks.php CHANGED
@@ -20,9 +20,83 @@ class gmediaPermalinks {
20
  add_filter('rewrite_rules_array', array($this, 'add_rewrite_rules'));
21
  add_filter('query_vars', array($this, 'add_query_vars'));
22
  add_action('parse_request', array($this, 'handler'));
 
23
 
24
  add_filter('post_thumbnail_html', array($this, 'gmedia_post_thumbnail'), 10, 5);
25
  add_filter('gmedia_shortcode_gallery_data', array($this, 'gmedia_shortcode_gallery_data'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
 
28
  /**
@@ -88,8 +162,7 @@ class gmediaPermalinks {
88
  public function handler($wp) {
89
  global $gmGallery;
90
  $endpoint = !empty($gmGallery->options['endpoint'])? $gmGallery->options['endpoint'] : 'gmedia';
91
-
92
- if(isset($wp->query_vars[$endpoint])) {
93
 
94
  global $wp_query;
95
  $wp_query->is_single = false;
@@ -137,6 +210,23 @@ class gmediaPermalinks {
137
 
138
  }
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  /**
141
  * Filter for the post content
142
  *
20
  add_filter('rewrite_rules_array', array($this, 'add_rewrite_rules'));
21
  add_filter('query_vars', array($this, 'add_query_vars'));
22
  add_action('parse_request', array($this, 'handler'));
23
+ add_action('parse_query', array($this, 'bridge'));
24
 
25
  add_filter('post_thumbnail_html', array($this, 'gmedia_post_thumbnail'), 10, 5);
26
  add_filter('gmedia_shortcode_gallery_data', array($this, 'gmedia_shortcode_gallery_data'));
27
+
28
+ add_filter('show_admin_bar', array($this, 'comments_admin_bar_hide'));
29
+ add_action('single_template', array($this, 'comments_gmedia_template_redirect'));
30
+ add_filter('comment_post_redirect', array($this, 'redirect_after_comment'), 10, 2);
31
+
32
+ }
33
+
34
+ /**
35
+ * Change the template used when the gmedia post permalink has ?comments
36
+ *
37
+ * @param string $templates
38
+ *
39
+ * @return string
40
+ */
41
+ function comments_gmedia_template_redirect($templates = "") {
42
+ //if(!in_array($post->post_type, array('gmedia','gmedia_album','gmedia_gallery','gmedia_filter'))) {
43
+ if(!(isset($_GET['comments']) && is_singular(array('gmedia', 'gmedia_album', 'gmedia_gallery', 'gmedia_filter')))) {
44
+ return $templates;
45
+ }
46
+
47
+ $templates = locate_template("gmedia_comments-popup.php", false);
48
+ if(empty($templates)) {
49
+ $templates = GMEDIA_ABSPATH . 'template/comments-popup.php';
50
+ }
51
+
52
+ return $templates;
53
+ }
54
+
55
+ /**
56
+ * @param $show_admin_bar
57
+ *
58
+ * @return string
59
+ */
60
+ function comments_admin_bar_hide($show_admin_bar) {
61
+ if(!(isset($_GET['comments']) && is_singular(array('gmedia', 'gmedia_album', 'gmedia_gallery', 'gmedia_filter')))) {
62
+ return $show_admin_bar;
63
+ }
64
+
65
+ return false;
66
+ }
67
+
68
+ /**
69
+ * @param $location
70
+ *
71
+ * @param $comment
72
+ *
73
+ * @return string
74
+ */
75
+ function redirect_after_comment($location, $comment) {
76
+ global $wpdb;
77
+
78
+ $queryParts = explode('#', $_SERVER["HTTP_REFERER"], 2);
79
+ $queryParts = explode('?', $queryParts[0], 2);
80
+ if(!(isset($queryParts[1]) && !empty($queryParts[1]))) {
81
+ return $location;
82
+ }
83
+ $queryParts = explode('&', $queryParts[1]);
84
+ $params = array();
85
+ foreach($queryParts as $param) {
86
+ $item = explode('=', $param);
87
+ $params[$item[0]] = isset($item[1])? $item[1] : '';
88
+ }
89
+ if(!isset($params['comments'])) {
90
+ return $location;
91
+ }
92
+
93
+ $post = get_post($comment->comment_post_ID);
94
+
95
+ if(!in_array($post->post_type, array('gmedia', 'gmedia_album', 'gmedia_gallery', 'gmedia_filter'))) {
96
+ return $location;
97
+ }
98
+
99
+ return $_SERVER["HTTP_REFERER"] . "#comment-" . $wpdb->insert_id;
100
  }
101
 
102
  /**
162
  public function handler($wp) {
163
  global $gmGallery;
164
  $endpoint = !empty($gmGallery->options['endpoint'])? $gmGallery->options['endpoint'] : 'gmedia';
165
+ if(isset($wp->query_vars[$endpoint]) && isset($wp->query_vars['t']) && in_array($wp->query_vars['t'], array('g', 'a', 't', 's', 'k', 'f', 'u'))) {
 
166
 
167
  global $wp_query;
168
  $wp_query->is_single = false;
210
 
211
  }
212
 
213
+ /**
214
+ * Listen for gmServiceLink query
215
+ *
216
+ * @access public
217
+ *
218
+ * @param $wp - global variable
219
+ */
220
+ public function bridge($wp) {
221
+ if (isset($_GET['gmServiceLink'])) {
222
+ $transient_key = preg_replace('/[^A-Za-z0-9]/', '', $_GET['gmServiceLink']);
223
+ if (false !== ($result = get_transient($transient_key))) {
224
+ header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
225
+ echo json_encode($result);
226
+ die();
227
+ }
228
+ }
229
+ }
230
  /**
231
  * Filter for the post content
232
  *
inc/post-metabox.php CHANGED
@@ -37,9 +37,9 @@ function gmedia_meta_box_load_scripts($hook)
37
  {
38
  if ((in_array($hook, array('post.php', 'edit.php')) && isset($_GET['post']) && isset($_GET['action']) && $_GET['action'] == 'edit') || $hook == 'post-new.php') {
39
  //wp_enqueue_style('wp-jquery-ui-dialog');
40
- //wp_enqueue_style('gmedia-meta-box', plugins_url(GMEDIA_FOLDER) . '/admin/css/gmedia.metabox.css', array('wp-jquery-ui-dialog'), '1.3.0');
41
- //wp_enqueue_script('gmedia-meta-box', plugins_url(GMEDIA_FOLDER) . '/admin/js/gmedia.metabox.js', array('jquery','jquery-ui-dialog','gmedia-global-backend'), '1.4.2', true);
42
- wp_enqueue_script('gmedia-meta-box', plugins_url(GMEDIA_FOLDER) . '/admin/js/gmedia.metabox.js', array('jquery', 'gmedia-global-backend'), '1.4.2', true);
43
  }
44
  }
45
 
@@ -50,7 +50,7 @@ function gmedia_post_modal_tpl()
50
  <script type="text/html" id="tpl__gm-uploader">
51
  <div id="__gm-uploader" tabindex="0">
52
  <div class="media-modal wp-core-ui">
53
- <a class="media-modal-close" style="line-height:50px;width:50px;height:50px;text-align:center;text-decoration:none;" href="javascript:void(0)"><span class="media-modal-icon" style="margin-top:0;"></span></a>
54
 
55
  <div class="media-modal-content">
56
  <div class="media-frame wp-core-ui hide-router hide-toolbar">
@@ -105,7 +105,7 @@ function gmedia_post_modal_tpl()
105
 
106
  function gmedia_tinymce_plugin( $plugin_array ) {
107
 
108
- $plugin_array['gmedia'] = plugins_url( GMEDIA_FOLDER ) . '/admin/js/tinymce_gmedia_plugin.js';
109
 
110
  return $plugin_array;
111
  }
@@ -115,7 +115,7 @@ return $plugin_array;
115
  function gmedia_post_metabox()
116
  {
117
  global $gmCore, $gmDB, $user_ID;
118
- $t = $gmCore->gmedia_url . '/admin/img/blank.gif';
119
  ?>
120
  <div id="gmedia-wraper">
121
  <div id="gmedia-message">
37
  {
38
  if ((in_array($hook, array('post.php', 'edit.php')) && isset($_GET['post']) && isset($_GET['action']) && $_GET['action'] == 'edit') || $hook == 'post-new.php') {
39
  //wp_enqueue_style('wp-jquery-ui-dialog');
40
+ //wp_enqueue_style('gmedia-meta-box', plugins_url(GMEDIA_FOLDER) . '/admin/assets/css/gmedia.metabox.css', array('wp-jquery-ui-dialog'), '1.3.0');
41
+ //wp_enqueue_script('gmedia-meta-box', plugins_url(GMEDIA_FOLDER) . '/admin/assets/js/gmedia.metabox.js', array('jquery','jquery-ui-dialog','gmedia-global-backend'), '1.4.2', true);
42
+ wp_enqueue_script('gmedia-meta-box', plugins_url(GMEDIA_FOLDER) . '/admin/assets/js/gmedia.metabox.js', array('jquery', 'gmedia-global-backend'), '1.4.2', true);
43
  }
44
  }
45
 
50
  <script type="text/html" id="tpl__gm-uploader">
51
  <div id="__gm-uploader" tabindex="0">
52
  <div class="media-modal wp-core-ui">
53
+ <a class="media-modal-close" style="right:0;top:0;line-height:40px;width:40px;height:40px;text-align:center;text-decoration:none;" href="javascript:void(0)"><span class="media-modal-icon" style="margin-top:0;"></span></a>
54
 
55
  <div class="media-modal-content">
56
  <div class="media-frame wp-core-ui hide-router hide-toolbar">
105
 
106
  function gmedia_tinymce_plugin( $plugin_array ) {
107
 
108
+ $plugin_array['gmedia'] = plugins_url( GMEDIA_FOLDER ) . '/admin/assets/js/gmedia.tinymce.js';
109
 
110
  return $plugin_array;
111
  }
115
  function gmedia_post_metabox()
116
  {
117
  global $gmCore, $gmDB, $user_ID;
118
+ $t = $gmCore->gmedia_url . '/admin/assets/img/blank.gif';
119
  ?>
120
  <div id="gmedia-wraper">
121
  <div id="gmedia-message">
inc/shortcodes.php CHANGED
@@ -109,7 +109,7 @@ function gmedia_shortcode($atts, $content = '')
109
  'term_id' => 0,
110
  'name' => '',
111
  'description' => '',
112
- 'status' => 'public',
113
  '_edited' => '&#8212;',
114
  '_module' => 'phantom',
115
  '_query' => array(),
@@ -193,7 +193,7 @@ function gmedia_shortcode($atts, $content = '')
193
  $terms = array();
194
  $gmedia = array();
195
  if (! empty($gallery['_query'])) {
196
- $gmedia_status = array('public');
197
  if (is_user_logged_in()) {
198
  $gmedia_status[] = 'private';
199
  }
109
  'term_id' => 0,
110
  'name' => '',
111
  'description' => '',
112
+ 'status' => 'publish',
113
  '_edited' => '&#8212;',
114
  '_module' => 'phantom',
115
  '_query' => array(),
193
  $terms = array();
194
  $gmedia = array();
195
  if (! empty($gallery['_query'])) {
196
+ $gmedia_status = array('publish');
197
  if (is_user_logged_in()) {
198
  $gmedia_status[] = 'private';
199
  }
load-template.php CHANGED
@@ -22,13 +22,14 @@ $template = array(
22
  'u' => 'author'
23
  );
24
  if (! isset($template[$type])) {
25
- locate_template(array('404'), true);
26
  exit();
27
  }
28
 
29
  $gmedia_type = $template[$type];
30
  $gmedia_id = gmedia_hash_id_decode($gmedia_hashid, $gmedia_type);
31
  if (empty($gmedia_id)) {
 
32
  exit();
33
  }
34
 
22
  'u' => 'author'
23
  );
24
  if (! isset($template[$type])) {
25
+ locate_template('404', true);
26
  exit();
27
  }
28
 
29
  $gmedia_type = $template[$type];
30
  $gmedia_id = gmedia_hash_id_decode($gmedia_hashid, $gmedia_type);
31
  if (empty($gmedia_id)) {
32
+ locate_template('404', true);
33
  exit();
34
  }
35
 
module/afflux/gallery.swf CHANGED
File without changes
module/afflux/img/loader.gif CHANGED
File without changes
module/afflux/index.php CHANGED
@@ -3,7 +3,7 @@ $module_info = array(
3
  'base' => 'afflux',
4
  'name' => 'afflux',
5
  'title' => 'Afflux',
6
- 'version' => '3.7',
7
  'author' => 'CodEasily.com',
8
  'description' => 'A Free Gallery Skin that supports thumbnails size change, color change, captions and autoplay. Responsive and mobile friendly gallery.',
9
  'type' => 'gallery',
3
  'base' => 'afflux',
4
  'name' => 'afflux',
5
  'title' => 'Afflux',
6
+ 'version' => '3.8',
7
  'author' => 'CodEasily.com',
8
  'description' => 'A Free Gallery Skin that supports thumbnails size change, color change, captions and autoplay. Responsive and mobile friendly gallery.',
9
  'type' => 'gallery',
module/afflux/js/jquery.gmAfflux.js CHANGED
@@ -1,6 +1,6 @@
1
  /*
2
  * Title : Afflux Gallery Module
3
- * Version : 3.7
4
  * Copyright : 2013-2015 CodEasily.com
5
  * Website : http://www.codeasily.com
6
  */
1
  /*
2
  * Title : Afflux Gallery Module
3
+ * Version : 3.8
4
  * Copyright : 2013-2015 CodEasily.com
5
  * Website : http://www.codeasily.com
6
  */
module/afflux/settings.php CHANGED
@@ -1 +1 @@
1
- <?php
2
  'maxwidth' => '0',
3
  'lockheight' => '0',
4
  'height' => '500',
5
  'maxheight' => '0',
6
  'imageZoom' => 'FILL',
7
  'autoSlideshow' => '1',
8
  'slideshowDelay' => '10',
9
  'thumbHeight' => '100',
10
  'descrVisOnMouseover' => '1',
11
  'wmode' => 'opaque',
12
  'bgColor' => 'ffffff',
13
  'imagesBgColor' => '000000',
14
  'barsBgColor' => '000000',
15
  'catButtonColor' => '75c30f',
16
  'catButtonColorHover' => 'ffffff',
17
  'scrollBarTrackColor' => '75c30f',
18
  'scrollBarButtonColor' => 'f1f1f1',
19
  'thumbBgColor' => 'ffffff',
20
  'thumbLoaderColor' => '75c30f',
21
  'imageTitleColor' => '75c30f',
22
  'imageTitleFontSize' => '14',
23
  'imageDescrColor' => 'ffffff',
24
  'imageDescrFontSize' => '12',
25
  'imageDescrBgColor' => '000000',
26
  'imageDescrBgAlpha' => '85',
27
  'customCSS' => ''
28
  array(
29
  'label' => 'Common Settings',
30
  'fields' => array(
31
  'maxwidth' => array(
32
  'label' => 'Max-Width',
33
  'tag' => 'input',
34
  'attr' => 'type="number" min="0"',
35
  'text' => 'By default gallery width always 100%. Set the maximum width of the gallery (in pixels). Leave 0 to disable max-width.'
36
  ),
37
  'lockheight' => array(
38
  'label' => 'Set height manually',
39
  'tag' => 'checkbox',
40
  'attr' => 'data-watch="change"',
41
  'text' => 'By default a gallery automatically calculates own height to best fit the tallest image in a gallery.'
42
  ),
43
  'height' => array(
44
  'label' => 'Height',
45
  'tag' => 'input',
46
  'attr' => 'type="text" min="0" data-lockheight="is:1"',
47
  'text' => 'Set height of the gallery. Do not set % unless you know what you doing.'
48
  ),
49
  'maxheight' => array(
50
  'label' => 'Max-Height',
51
  'tag' => 'input',
52
  'attr' => 'type="number" min="0" data-lockheight="is:0"',
53
  'text' => 'Set the maximum height of the gallery. Leave 0 to disable max-height.'
54
  ),
55
  'imageZoom' => array(
56
  'label' => 'Image Zoom',
57
  'tag' => 'select',
58
  'attr' => '',
59
  'text' => 'Default value: Fill.',
60
  'choices' => array(
61
  array(
62
  'label' => 'Fill',
63
  'value' => 'FILL'
64
  ),
65
  array(
66
  'label' => 'Fit',
67
  'value' => 'FIT'
68
  )
69
  )
70
  ),
71
  'autoSlideshow' => array(
72
  'label' => 'Automatic Slideshow (On/Off)',
73
  'tag' => 'checkbox',
74
  'attr' => '',
75
  'text' => ''
76
  ),
77
  'slideshowDelay' => array(
78
  'label' => 'Slideshow Delay',
79
  'tag' => 'input',
80
  'attr' => 'type="number" min="1" max="60"',
81
  'text' => 'Set delay between slides in seconds'
82
  ),
83
  'thumbHeight' => array(
84
  'label' => 'Thumbnails Height',
85
  'tag' => 'input',
86
  'attr' => 'type="number" min="0" max="300"',
87
  'text' => 'Set bottom thumbnails row height in pixels'
88
  ),
89
  'descrVisOnMouseover' => array(
90
  'label' => 'Show Description',
91
  'tag' => 'checkbox',
92
  'attr' => '',
93
  'text' => 'Show image description on mouseover'
94
  )
95
  /*,
96
  'hitcounter' => array(
97
  'label' => 'Count Image Views',
98
  'tag' => 'checkbox',
99
  'attr' => '',
100
  'text' => ''
101
  )*/
102
  )
103
  ),
104
  array(
105
  'label' => 'Colors and Fonts',
106
  'fields' => array(
107
  'wmode' => array(
108
  'label' => 'Wmode for flash object',
109
  'tag' => 'select',
110
  'attr' => 'data-watch="change"',
111
  'text' => 'Default value: Opaque. If \'transparent\' - "Background Color" option is ignored, but you can position the absolute elements over the flash',
112
  'choices' => array(
113
  array(
114
  'label' => 'Opaque',
115
  'value' => 'opaque'
116
  ),
117
  array(
118
  'label' => 'Window',
119
  'value' => 'window'
120
  ),
121
  array(
122
  'label' => 'Transparent',
123
  'value' => 'transparent'
124
  )
125
  )
126
  ),
127
  'bgColor' => array(
128
  'label' => 'Background Color',
129
  'tag' => 'input',
130
  'attr' => 'type="text" data-type="color" data-wmode="not:transparent"',
131
  'text' => 'Set gallery background color'
132
  ),
133
  'imagesBgColor' => array(
134
  'label' => 'Images Background Color',
135
  'tag' => 'input',
136
  'attr' => 'type="text" data-type="color"',
137
  'text' => 'Set loading images background color'
138
  ),
139
  'barsBgColor' => array(
140
  'label' => 'Bars Background Color',
141
  'tag' => 'input',
142
  'attr' => 'type="text" data-type="color"',
143
  'text' => 'Background color for Menu bar, Thumbnails bar and Scroll bar'
144
  ),
145
  'catButtonColor' => array(
146
  'label' => 'Menu Bar Buttons Color',
147
  'tag' => 'input',
148
  'attr' => 'type="text" data-type="color"',
149
  'text' => ''
150
  ),
151
  'catButtonColorHover' => array(
152
  'label' => 'Menu Bar Buttons Color on Mouseover',
153
  'tag' => 'input',
154
  'attr' => 'type="text" data-type="color"',
155
  'text' => ''
156
  ),
157
  'scrollBarTrackColor' => array(
158
  'label' => 'Scroll Bar Track Color',
159
  'tag' => 'input',
160
  'attr' => 'type="text" data-type="color"',
161
  'text' => ''
162
  ),
163
  'scrollBarButtonColor' => array(
164
  'label' => 'Scroll Bar Button Color',
165
  'tag' => 'input',
166
  'attr' => 'type="text" data-type="color"',
167
  'text' => ''
168
  ),
169
  'thumbBgColor' => array(
170
  'label' => 'Thumbnail BG Color',
171
  'tag' => 'input',
172
  'attr' => 'type="text" data-type="color"',
173
  'text' => 'Background of the thumbnail placeholder while thumbnail is loading'
174
  ),
175
  'thumbLoaderColor' => array(
176
  'label' => 'Thumbnail Loader Color',
177
  'tag' => 'input',
178
  'attr' => 'type="text" data-type="color"',
179
  'text' => ''
180
  ),
181
  'imageTitleColor' => array(
182
  'label' => 'Image Title Color',
183
  'tag' => 'input',
184
  'attr' => 'type="text" data-type="color"',
185
  'text' => 'Color for image title text'
186
  ),
187
  'imageTitleFontSize' => array(
188
  'label' => 'Image Title Font Size',
189
  'tag' => 'input',
190
  'attr' => 'type="number" min="10" max="30"',
191
  'text' => ''
192
  ),
193
  'imageDescrColor' => array(
194
  'label' => 'Image Description Color',
195
  'tag' => 'input',
196
  'attr' => 'type="text" data-type="color"',
197
  'text' => 'Color for image description text'
198
  ),
199
  'imageDescrFontSize' => array(
200
  'label' => 'Image Description Font Size',
201
  'tag' => 'input',
202
  'attr' => 'type="number" min="10" max="30"',
203
  'text' => ''
204
  ),
205
  'imageDescrBgColor' => array(
206
  'label' => 'Image Description BG Color',
207
  'tag' => 'input',
208
  'attr' => 'type="text" data-type="color"',
209
  'text' => 'Background color for the description pane that appears on mouseover'
210
  ),
211
  'imageDescrBgAlpha' => array(
212
  'label' => 'Image Description Background Alpha',
213
  'tag' => 'input',
214
  'attr' => 'type="number" min="0" max="100" step="5"',
215
  'text' => 'Opacity of the description pane background'
216
  )
217
  /*,
218
  'backButtonTextColor' => array(
219
  'label' => 'Back Button Text Color',
220
  'tag' => 'input',
221
  'attr' => 'type="text" data-type="color"',
222
  'text' => '(only for Full Window template). Default: ffffff'
223
  ),
224
  'backButtonBgColor' => array(
225
  'label' => 'Back Button Background Color',
226
  'tag' => 'input',
227
  'attr' => 'type="text" data-type="color"',
228
  'desc' => '(only for Full Window template). Default: 000000'
229
  )*/
230
  )
231
  ),
232
  array(
233
  'label' => 'Advanced Settings',
234
  'fields' => array(
235
  'customCSS' => array(
236
  'label' => 'Custom CSS',
237
  'tag' => 'textarea',
238
  'attr' => 'cols="20" rows="10"',
239
  'text' => 'You can enter custom style rules into this box if you\'d like. IE: <i>a{color: red !important;}</i><br />This is an advanced option! This is not recommended for users not fluent in CSS... but if you do know CSS, anything you add here will override the default styles'
240
  )
241
  /*,
242
  'loveLink' => array(
243
  'label' => 'Display LoveLink?',
244
  'tag' => 'checkbox',
245
  'attr' => '',
246
  'text' => 'Selecting "Yes" will show the lovelink icon (codeasily.com) somewhere on the gallery'
247
  )*/
248
  )
249
  )
 
250
  'maxwidth' => '0',
251
  'lockheight' => '1',
252
  'height' => '500',
253
  'maxheight' => '0',
254
  'imageZoom' => 'FILL',
255
  'autoSlideshow' => '1',
256
  'slideshowDelay' => '10',
257
  'thumbHeight' => '100',
258
  'descrVisOnMouseover' => '1',
259
  'wmode' => 'opaque',
260
  'bgColor' => 'ffffff',
261
  'imagesBgColor' => '000000',
262
  'barsBgColor' => '000000',
263
  'catButtonColor' => '75c30f',
264
  'catButtonColorHover' => 'ffffff',
265
  'scrollBarTrackColor' => '75c30f',
266
  'scrollBarButtonColor' => 'f1f1f1',
267
  'thumbBgColor' => 'ffffff',
268
  'thumbLoaderColor' => '75c30f',
269
  'imageTitleColor' => '75c30f',
270
  'imageTitleFontSize' => '14',
271
  'imageDescrColor' => 'ffffff',
272
  'imageDescrFontSize' => '12',
273
  'imageDescrBgColor' => '000000',
274
  'imageDescrBgAlpha' => '85',
275
  'customCSS' => ''
276
  array(
277
  'label' => 'Common Settings',
278
  'fields' => array(
279
  'maxwidth' => array(
280
  'label' => 'Max-Width',
281
  'tag' => 'input',
282
  'attr' => 'type="number" min="0"',
283
  'text' => 'By default gallery width always 100%. Set the maximum width of the gallery (in pixels). Leave 0 to disable max-width.'
284
  ),
285
  'lockheight' => array(
286
  'label' => 'Set height manually',
287
  'tag' => 'checkbox',
288
  'attr' => 'data-watch="change"',
289
  'text' => 'By default a gallery automatically calculates own height to best fit the tallest image in a gallery.'
290
  ),
291
  'height' => array(
292
  'label' => 'Height',
293
  'tag' => 'input',
294
  'attr' => 'type="text" min="0" data-lockheight="is:1"',
295
  'text' => 'Set height of the gallery. Do not set % unless you know what you doing.'
296
  ),
297
  'maxheight' => array(
298
  'label' => 'Max-Height',
299
  'tag' => 'input',
300
  'attr' => 'type="number" min="0" data-lockheight="is:0"',
301
  'text' => 'Set the maximum height of the gallery. Leave 0 to disable max-height.'
302
  ),
303
  'imageZoom' => array(
304
  'label' => 'Image Zoom',
305
  'tag' => 'select',
306
  'attr' => '',
307
  'text' => 'Default value: Fill.',
308
  'choices' => array(
309
  array(
310
  'label' => 'Fill',
311
  'value' => 'FILL'
312
  ),
313
  array(
314
  'label' => 'Fit',
315
  'value' => 'FIT'
316
  )
317
  )
318
  ),
319
  'autoSlideshow' => array(
320
  'label' => 'Automatic Slideshow (On/Off)',
321
  'tag' => 'checkbox',
322
  'attr' => '',
323
  'text' => ''
324
  ),
325
  'slideshowDelay' => array(
326
  'label' => 'Slideshow Delay',
327
  'tag' => 'input',
328
  'attr' => 'type="number" min="1" max="60"',
329
  'text' => 'Set delay between slides in seconds'
330
  ),
331
  'thumbHeight' => array(
332
  'label' => 'Thumbnails Height',
333
  'tag' => 'input',
334
  'attr' => 'type="number" min="0" max="300"',
335
  'text' => 'Set bottom thumbnails row height in pixels'
336
  ),
337
  'descrVisOnMouseover' => array(
338
  'label' => 'Show Description',
339
  'tag' => 'checkbox',
340
  'attr' => '',
341
  'text' => 'Show image description on mouseover'
342
  )
343
  /*,
344
  'hitcounter' => array(
345
  'label' => 'Count Image Views',
346
  'tag' => 'checkbox',
347
  'attr' => '',
348
  'text' => ''
349
  )*/
350
  )
351
  ),
352
  array(
353
  'label' => 'Colors and Fonts',
354
  'fields' => array(
355
  'wmode' => array(
356
  'label' => 'Wmode for flash object',
357
  'tag' => 'select',
358
  'attr' => 'data-watch="change"',
359
  'text' => 'Default value: Opaque. If \'transparent\' - "Background Color" option is ignored, but you can position the absolute elements over the flash',
360
  'choices' => array(
361
  array(
362
  'label' => 'Opaque',
363
  'value' => 'opaque'
364
  ),
365
  array(
366
  'label' => 'Window',
367
  'value' => 'window'
368
  ),
369
  array(
370
  'label' => 'Transparent',
371
  'value' => 'transparent'
372
  )
373
  )
374
  ),
375
  'bgColor' => array(
376
  'label' => 'Background Color',
377
  'tag' => 'input',
378
  'attr' => 'type="text" data-type="color" data-wmode="not:transparent"',
379
  'text' => 'Set gallery background color'
380
  ),
381
  'imagesBgColor' => array(
382
  'label' => 'Images Background Color',
383
  'tag' => 'input',
384
  'attr' => 'type="text" data-type="color"',
385
  'text' => 'Set loading images background color'
386
  ),
387
  'barsBgColor' => array(
388
  'label' => 'Bars Background Color',
389
  'tag' => 'input',
390
  'attr' => 'type="text" data-type="color"',
391
  'text' => 'Background color for Menu bar, Thumbnails bar and Scroll bar'
392
  ),
393
  'catButtonColor' => array(
394
  'label' => 'Menu Bar Buttons Color',
395
  'tag' => 'input',
396
  'attr' => 'type="text" data-type="color"',
397
  'text' => ''
398
  ),
399
  'catButtonColorHover' => array(
400
  'label' => 'Menu Bar Buttons Color on Mouseover',
401
  'tag' => 'input',
402
  'attr' => 'type="text" data-type="color"',
403
  'text' => ''
404
  ),
405
  'scrollBarTrackColor' => array(
406
  'label' => 'Scroll Bar Track Color',
407
  'tag' => 'input',
408
  'attr' => 'type="text" data-type="color"',
409
  'text' => ''
410
  ),
411
  'scrollBarButtonColor' => array(
412
  'label' => 'Scroll Bar Button Color',
413
  'tag' => 'input',
414
  'attr' => 'type="text" data-type="color"',
415
  'text' => ''
416
  ),
417
  'thumbBgColor' => array(
418
  'label' => 'Thumbnail BG Color',
419
  'tag' => 'input',
420
  'attr' => 'type="text" data-type="color"',
421
  'text' => 'Background of the thumbnail placeholder while thumbnail is loading'
422
  ),
423
  'thumbLoaderColor' => array(
424
  'label' => 'Thumbnail Loader Color',
425
  'tag' => 'input',
426
  'attr' => 'type="text" data-type="color"',
427
  'text' => ''
428
  ),
429
  'imageTitleColor' => array(
430
  'label' => 'Image Title Color',
431
  'tag' => 'input',
432
  'attr' => 'type="text" data-type="color"',
433
  'text' => 'Color for image title text'
434
  ),
435
  'imageTitleFontSize' => array(
436
  'label' => 'Image Title Font Size',
437
  'tag' => 'input',
438
  'attr' => 'type="number" min="10" max="30"',
439
  'text' => ''
440
  ),
441
  'imageDescrColor' => array(
442
  'label' => 'Image Description Color',
443
  'tag' => 'input',
444
  'attr' => 'type="text" data-type="color"',
445
  'text' => 'Color for image description text'
446
  ),
447
  'imageDescrFontSize' => array(
448
  'label' => 'Image Description Font Size',
449
  'tag' => 'input',
450
  'attr' => 'type="number" min="10" max="30"',
451
  'text' => ''
452
  ),
453
  'imageDescrBgColor' => array(
454
  'label' => 'Image Description BG Color',
455
  'tag' => 'input',
456
  'attr' => 'type="text" data-type="color"',
457
  'text' => 'Background color for the description pane that appears on mouseover'
458
  ),
459
  'imageDescrBgAlpha' => array(
460
  'label' => 'Image Description Background Alpha',
461
  'tag' => 'input',
462
  'attr' => 'type="number" min="0" max="100" step="5"',
463
  'text' => 'Opacity of the description pane background'
464
  )
465
  /*,
466
  'backButtonTextColor' => array(
467
  'label' => 'Back Button Text Color',
468
  'tag' => 'input',
469
  'attr' => 'type="text" data-type="color"',
470
  'text' => '(only for Full Window template). Default: ffffff'
471
  ),
472
  'backButtonBgColor' => array(
473
  'label' => 'Back Button Background Color',
474
  'tag' => 'input',
475
  'attr' => 'type="text" data-type="color"',
476
  'desc' => '(only for Full Window template). Default: 000000'
477
  )*/
478
  )
479
  ),
480
  array(
481
  'label' => 'Advanced Settings',
482
  'fields' => array(
483
  'customCSS' => array(
484
  'label' => 'Custom CSS',
485
  'tag' => 'textarea',
486
  'attr' => 'cols="20" rows="10"',
487
  'text' => 'You can enter custom style rules into this box if you\'d like. IE: <i>a{color: red !important;}</i><br />This is an advanced option! This is not recommended for users not fluent in CSS... but if you do know CSS, anything you add here will override the default styles'
488
  )
489
  /*,
490
  'loveLink' => array(
491
  'label' => 'Display LoveLink?',
492
  'tag' => 'checkbox',
493
  'attr' => '',
494
  'text' => 'Selecting "Yes" will show the lovelink icon (codeasily.com) somewhere on the gallery'
495
  )*/
496
  )
497
  )
 
1
  'maxwidth' => '0',
2
  'lockheight' => '0',
3
  'height' => '500',
4
  'maxheight' => '0',
5
  'imageZoom' => 'FILL',
6
  'autoSlideshow' => '1',
7
  'slideshowDelay' => '10',
8
  'thumbHeight' => '100',
9
  'descrVisOnMouseover' => '1',
10
  'wmode' => 'opaque',
11
  'bgColor' => 'ffffff',
12
  'imagesBgColor' => '000000',
13
  'barsBgColor' => '000000',
14
  'catButtonColor' => '75c30f',
15
  'catButtonColorHover' => 'ffffff',
16
  'scrollBarTrackColor' => '75c30f',
17
  'scrollBarButtonColor' => 'f1f1f1',
18
  'thumbBgColor' => 'ffffff',
19
  'thumbLoaderColor' => '75c30f',
20
  'imageTitleColor' => '75c30f',
21
  'imageTitleFontSize' => '14',
22
  'imageDescrColor' => 'ffffff',
23
  'imageDescrFontSize' => '12',
24
  'imageDescrBgColor' => '000000',
25
  'imageDescrBgAlpha' => '85',
26
  'customCSS' => ''
27
  array(
28
  'label' => 'Common Settings',
29
  'fields' => array(
30
  'maxwidth' => array(
31
  'label' => 'Max-Width',
32
  'tag' => 'input',
33
  'attr' => 'type="number" min="0"',
34
  'text' => 'By default gallery width always 100%. Set the maximum width of the gallery (in pixels). Leave 0 to disable max-width.'
35
  ),
36
  'lockheight' => array(
37
  'label' => 'Set height manually',
38
  'tag' => 'checkbox',
39
  'attr' => 'data-watch="change"',
40
  'text' => 'By default a gallery automatically calculates own height to best fit the tallest image in a gallery.'
41
  ),
42
  'height' => array(
43
  'label' => 'Height',
44
  'tag' => 'input',
45
  'attr' => 'type="text" min="0" data-lockheight="is:1"',
46
  'text' => 'Set height of the gallery. Do not set % unless you know what you doing.'
47
  ),
48
  'maxheight' => array(
49
  'label' => 'Max-Height',
50
  'tag' => 'input',
51
  'attr' => 'type="number" min="0" data-lockheight="is:0"',
52
  'text' => 'Set the maximum height of the gallery. Leave 0 to disable max-height.'
53
  ),
54
  'imageZoom' => array(
55
  'label' => 'Image Zoom',
56
  'tag' => 'select',
57
  'attr' => '',
58
  'text' => 'Default value: Fill.',
59
  'choices' => array(
60
  array(
61
  'label' => 'Fill',
62
  'value' => 'FILL'
63
  ),
64
  array(
65
  'label' => 'Fit',
66
  'value' => 'FIT'
67
  )
68
  )
69
  ),
70
  'autoSlideshow' => array(
71
  'label' => 'Automatic Slideshow (On/Off)',
72
  'tag' => 'checkbox',
73
  'attr' => '',
74
  'text' => ''
75
  ),
76
  'slideshowDelay' => array(
77
  'label' => 'Slideshow Delay',
78
  'tag' => 'input',
79
  'attr' => 'type="number" min="1" max="60"',
80
  'text' => 'Set delay between slides in seconds'
81
  ),
82
  'thumbHeight' => array(
83
  'label' => 'Thumbnails Height',
84
  'tag' => 'input',
85
  'attr' => 'type="number" min="0" max="300"',
86
  'text' => 'Set bottom thumbnails row height in pixels'
87
  ),
88
  'descrVisOnMouseover' => array(
89
  'label' => 'Show Description',
90
  'tag' => 'checkbox',
91
  'attr' => '',
92
  'text' => 'Show image description on mouseover'
93
  )
94
  /*,
95
  'hitcounter' => array(
96
  'label' => 'Count Image Views',
97
  'tag' => 'checkbox',
98
  'attr' => '',
99
  'text' => ''
100
  )*/
101
  )
102
  ),
103
  array(
104
  'label' => 'Colors and Fonts',
105
  'fields' => array(
106
  'wmode' => array(
107
  'label' => 'Wmode for flash object',
108
  'tag' => 'select',
109
  'attr' => 'data-watch="change"',
110
  'text' => 'Default value: Opaque. If \'transparent\' - "Background Color" option is ignored, but you can position the absolute elements over the flash',
111
  'choices' => array(
112
  array(
113
  'label' => 'Opaque',
114
  'value' => 'opaque'
115
  ),
116
  array(
117
  'label' => 'Window',
118
  'value' => 'window'
119
  ),
120
  array(
121
  'label' => 'Transparent',
122
  'value' => 'transparent'
123
  )
124
  )
125
  ),
126
  'bgColor' => array(
127
  'label' => 'Background Color',
128
  'tag' => 'input',
129
  'attr' => 'type="text" data-type="color" data-wmode="not:transparent"',
130
  'text' => 'Set gallery background color'
131
  ),
132
  'imagesBgColor' => array(
133
  'label' => 'Images Background Color',
134
  'tag' => 'input',
135
  'attr' => 'type="text" data-type="color"',
136
  'text' => 'Set loading images background color'
137
  ),
138
  'barsBgColor' => array(
139
  'label' => 'Bars Background Color',
140
  'tag' => 'input',
141
  'attr' => 'type="text" data-type="color"',
142
  'text' => 'Background color for Menu bar, Thumbnails bar and Scroll bar'
143
  ),
144
  'catButtonColor' => array(
145
  'label' => 'Menu Bar Buttons Color',
146
  'tag' => 'input',
147
  'attr' => 'type="text" data-type="color"',
148
  'text' => ''
149
  ),
150
  'catButtonColorHover' => array(
151
  'label' => 'Menu Bar Buttons Color on Mouseover',
152
  'tag' => 'input',
153
  'attr' => 'type="text" data-type="color"',
154
  'text' => ''
155
  ),
156
  'scrollBarTrackColor' => array(
157
  'label' => 'Scroll Bar Track Color',
158
  'tag' => 'input',
159
  'attr' => 'type="text" data-type="color"',
160
  'text' => ''
161
  ),
162
  'scrollBarButtonColor' => array(
163
  'label' => 'Scroll Bar Button Color',
164
  'tag' => 'input',
165
  'attr' => 'type="text" data-type="color"',
166
  'text' => ''
167
  ),
168
  'thumbBgColor' => array(
169
  'label' => 'Thumbnail BG Color',
170
  'tag' => 'input',
171
  'attr' => 'type="text" data-type="color"',
172
  'text' => 'Background of the thumbnail placeholder while thumbnail is loading'
173
  ),
174
  'thumbLoaderColor' => array(
175
  'label' => 'Thumbnail Loader Color',
176
  'tag' => 'input',
177
  'attr' => 'type="text" data-type="color"',
178
  'text' => ''
179
  ),
180
  'imageTitleColor' => array(
181
  'label' => 'Image Title Color',
182
  'tag' => 'input',
183
  'attr' => 'type="text" data-type="color"',
184
  'text' => 'Color for image title text'
185
  ),
186
  'imageTitleFontSize' => array(
187
  'label' => 'Image Title Font Size',
188
  'tag' => 'input',
189
  'attr' => 'type="number" min="10" max="30"',
190
  'text' => ''
191
  ),
192
  'imageDescrColor' => array(
193
  'label' => 'Image Description Color',
194
  'tag' => 'input',
195
  'attr' => 'type="text" data-type="color"',
196
  'text' => 'Color for image description text'
197
  ),
198
  'imageDescrFontSize' => array(
199
  'label' => 'Image Description Font Size',
200
  'tag' => 'input',
201
  'attr' => 'type="number" min="10" max="30"',
202
  'text' => ''
203
  ),
204
  'imageDescrBgColor' => array(
205
  'label' => 'Image Description BG Color',
206
  'tag' => 'input',
207
  'attr' => 'type="text" data-type="color"',
208
  'text' => 'Background color for the description pane that appears on mouseover'
209
  ),
210
  'imageDescrBgAlpha' => array(
211
  'label' => 'Image Description Background Alpha',
212
  'tag' => 'input',
213
  'attr' => 'type="number" min="0" max="100" step="5"',
214
  'text' => 'Opacity of the description pane background'
215
  )
216
  /*,
217
  'backButtonTextColor' => array(
218
  'label' => 'Back Button Text Color',
219
  'tag' => 'input',
220
  'attr' => 'type="text" data-type="color"',
221
  'text' => '(only for Full Window template). Default: ffffff'
222
  ),
223
  'backButtonBgColor' => array(
224
  'label' => 'Back Button Background Color',
225
  'tag' => 'input',
226
  'attr' => 'type="text" data-type="color"',
227
  'desc' => '(only for Full Window template). Default: 000000'
228
  )*/
229
  )
230
  ),
231
  array(
232
  'label' => 'Advanced Settings',
233
  'fields' => array(
234
  'customCSS' => array(
235
  'label' => 'Custom CSS',
236
  'tag' => 'textarea',
237
  'attr' => 'cols="20" rows="10"',
238
  'text' => 'You can enter custom style rules into this box if you\'d like. IE: <i>a{color: red !important;}</i><br />This is an advanced option! This is not recommended for users not fluent in CSS... but if you do know CSS, anything you add here will override the default styles'
239
  )
240
  /*,
241
  'loveLink' => array(
242
  'label' => 'Display LoveLink?',
243
  'tag' => 'checkbox',
244
  'attr' => '',
245
  'text' => 'Selecting "Yes" will show the lovelink icon (codeasily.com) somewhere on the gallery'
246
  )*/
247
  )
248
  )
249
+ <?php
250
  'maxwidth' => '0',
251
  'lockheight' => '1',
252
  'height' => '500',
253
  'maxheight' => '0',
254
  'imageZoom' => 'FILL',
255
  'autoSlideshow' => '1',
256
  'slideshowDelay' => '10',
257
  'thumbHeight' => '100',
258
  'descrVisOnMouseover' => '1',
259
  'wmode' => 'opaque',
260
  'bgColor' => 'ffffff',
261
  'imagesBgColor' => '000000',
262
  'barsBgColor' => '000000',
263
  'catButtonColor' => '75c30f',
264
  'catButtonColorHover' => 'ffffff',
265
  'scrollBarTrackColor' => '75c30f',
266
  'scrollBarButtonColor' => 'f1f1f1',
267
  'thumbBgColor' => 'ffffff',
268
  'thumbLoaderColor' => '75c30f',
269
  'imageTitleColor' => '75c30f',
270
  'imageTitleFontSize' => '14',
271
  'imageDescrColor' => 'ffffff',
272
  'imageDescrFontSize' => '12',
273
  'imageDescrBgColor' => '000000',
274
  'imageDescrBgAlpha' => '85',
275
  'customCSS' => ''
276
  array(
277
  'label' => 'Common Settings',
278
  'fields' => array(
279
  'maxwidth' => array(
280
  'label' => 'Max-Width',
281
  'tag' => 'input',
282
  'attr' => 'type="number" min="0"',
283
  'text' => 'By default gallery width always 100%. Set the maximum width of the gallery (in pixels). Leave 0 to disable max-width.'
284
  ),
285
  'lockheight' => array(
286
  'label' => 'Set height manually',
287
  'tag' => 'checkbox',
288
  'attr' => 'data-watch="change"',
289
  'text' => 'By default a gallery automatically calculates own height to best fit the tallest image in a gallery.'
290
  ),
291
  'height' => array(
292
  'label' => 'Height',
293
  'tag' => 'input',
294
  'attr' => 'type="text" min="0" data-lockheight="is:1"',
295
  'text' => 'Set height of the gallery. Do not set % unless you know what you doing.'
296
  ),
297
  'maxheight' => array(
298
  'label' => 'Max-Height',
299
  'tag' => 'input',
300
  'attr' => 'type="number" min="0" data-lockheight="is:0"',
301
  'text' => 'Set the maximum height of the gallery. Leave 0 to disable max-height.'
302
  ),
303
  'imageZoom' => array(
304
  'label' => 'Image Zoom',
305
  'tag' => 'select',
306
  'attr' => '',
307
  'text' => 'Default value: Fill.',
308
  'choices' => array(
309
  array(
310
  'label' => 'Fill',
311
  'value' => 'FILL'
312
  ),
313
  array(
314
  'label' => 'Fit',
315
  'value' => 'FIT'
316
  )
317
  )
318
  ),
319
  'autoSlideshow' => array(
320
  'label' => 'Automatic Slideshow (On/Off)',
321
  'tag' => 'checkbox',
322
  'attr' => '',
323
  'text' => ''
324
  ),
325
  'slideshowDelay' => array(
326
  'label' => 'Slideshow Delay',
327
  'tag' => 'input',
328
  'attr' => 'type="number" min="1" max="60"',
329
  'text' => 'Set delay between slides in seconds'
330
  ),
331
  'thumbHeight' => array(
332
  'label' => 'Thumbnails Height',
333
  'tag' => 'input',
334
  'attr' => 'type="number" min="0" max="300"',
335
  'text' => 'Set bottom thumbnails row height in pixels'
336
  ),
337
  'descrVisOnMouseover' => array(
338
  'label' => 'Show Description',
339
  'tag' => 'checkbox',
340
  'attr' => '',
341
  'text' => 'Show image description on mouseover'
342
  )
343
  /*,
344
  'hitcounter' => array(
345
  'label' => 'Count Image Views',
346
  'tag' => 'checkbox',
347
  'attr' => '',
348
  'text' => ''
349
  )*/
350
  )
351
  ),
352
  array(
353
  'label' => 'Colors and Fonts',
354
  'fields' => array(
355
  'wmode' => array(
356
  'label' => 'Wmode for flash object',
357
  'tag' => 'select',
358
  'attr' => 'data-watch="change"',
359
  'text' => 'Default value: Opaque. If \'transparent\' - "Background Color" option is ignored, but you can position the absolute elements over the flash',
360
  'choices' => array(
361
  array(
362
  'label' => 'Opaque',
363
  'value' => 'opaque'
364
  ),
365
  array(
366
  'label' => 'Window',
367
  'value' => 'window'
368
  ),
369
  array(
370
  'label' => 'Transparent',
371
  'value' => 'transparent'
372
  )
373
  )
374
  ),
375
  'bgColor' => array(
376
  'label' => 'Background Color',
377
  'tag' => 'input',
378
  'attr' => 'type="text" data-type="color" data-wmode="not:transparent"',
379
  'text' => 'Set gallery background color'
380
  ),
381
  'imagesBgColor' => array(
382
  'label' => 'Images Background Color',
383
  'tag' => 'input',
384
  'attr' => 'type="text" data-type="color"',
385
  'text' => 'Set loading images background color'
386
  ),
387
  'barsBgColor' => array(
388
  'label' => 'Bars Background Color',
389
  'tag' => 'input',
390
  'attr' => 'type="text" data-type="color"',
391
  'text' => 'Background color for Menu bar, Thumbnails bar and Scroll bar'
392
  ),
393
  'catButtonColor' => array(
394
  'label' => 'Menu Bar Buttons Color',
395
  'tag' => 'input',
396
  'attr' => 'type="text" data-type="color"',
397
  'text' => ''
398
  ),
399
  'catButtonColorHover' => array(
400
  'label' => 'Menu Bar Buttons Color on Mouseover',
401
  'tag' => 'input',
402
  'attr' => 'type="text" data-type="color"',
403
  'text' => ''
404
  ),
405
  'scrollBarTrackColor' => array(
406
  'label' => 'Scroll Bar Track Color',
407
  'tag' => 'input',
408
  'attr' => 'type="text" data-type="color"',
409
  'text' => ''
410
  ),
411
  'scrollBarButtonColor' => array(
412
  'label' => 'Scroll Bar Button Color',
413
  'tag' => 'input',
414
  'attr' => 'type="text" data-type="color"',
415
  'text' => ''
416
  ),
417
  'thumbBgColor' => array(
418
  'label' => 'Thumbnail BG Color',
419
  'tag' => 'input',
420
  'attr' => 'type="text" data-type="color"',
421
  'text' => 'Background of the thumbnail placeholder while thumbnail is loading'
422
  ),
423
  'thumbLoaderColor' => array(
424
  'label' => 'Thumbnail Loader Color',
425
  'tag' => 'input',
426
  'attr' => 'type="text" data-type="color"',
427
  'text' => ''
428
  ),
429
  'imageTitleColor' => array(
430
  'label' => 'Image Title Color',
431
  'tag' => 'input',
432
  'attr' => 'type="text" data-type="color"',
433
  'text' => 'Color for image title text'
434
  ),
435
  'imageTitleFontSize' => array(
436
  'label' => 'Image Title Font Size',
437
  'tag' => 'input',
438
  'attr' => 'type="number" min="10" max="30"',
439
  'text' => ''
440
  ),
441
  'imageDescrColor' => array(
442
  'label' => 'Image Description Color',
443
  'tag' => 'input',
444
  'attr' => 'type="text" data-type="color"',
445
  'text' => 'Color for image description text'
446
  ),
447
  'imageDescrFontSize' => array(
448
  'label' => 'Image Description Font Size',
449
  'tag' => 'input',
450
  'attr' => 'type="number" min="10" max="30"',
451
  'text' => ''
452
  ),
453
  'imageDescrBgColor' => array(
454
  'label' => 'Image Description BG Color',
455
  'tag' => 'input',
456
  'attr' => 'type="text" data-type="color"',
457
  'text' => 'Background color for the description pane that appears on mouseover'
458
  ),
459
  'imageDescrBgAlpha' => array(
460
  'label' => 'Image Description Background Alpha',
461
  'tag' => 'input',
462
  'attr' => 'type="number" min="0" max="100" step="5"',
463
  'text' => 'Opacity of the description pane background'
464
  )
465
  /*,
466
  'backButtonTextColor' => array(
467
  'label' => 'Back Button Text Color',
468
  'tag' => 'input',
469
  'attr' => 'type="text" data-type="color"',
470
  'text' => '(only for Full Window template). Default: ffffff'
471
  ),
472
  'backButtonBgColor' => array(
473
  'label' => 'Back Button Background Color',
474
  'tag' => 'input',
475
  'attr' => 'type="text" data-type="color"',
476
  'desc' => '(only for Full Window template). Default: 000000'
477
  )*/
478
  )
479
  ),
480
  array(
481
  'label' => 'Advanced Settings',
482
  'fields' => array(
483
  'customCSS' => array(
484
  'label' => 'Custom CSS',
485
  'tag' => 'textarea',
486
  'attr' => 'cols="20" rows="10"',
487
  'text' => 'You can enter custom style rules into this box if you\'d like. IE: <i>a{color: red !important;}</i><br />This is an advanced option! This is not recommended for users not fluent in CSS... but if you do know CSS, anything you add here will override the default styles'
488
  )
489
  /*,
490
  'loveLink' => array(
491
  'label' => 'Display LoveLink?',
492
  'tag' => 'checkbox',
493
  'attr' => '',
494
  'text' => 'Selecting "Yes" will show the lovelink icon (codeasily.com) somewhere on the gallery'
495
  )*/
496
  )
497
  )
module/jq-mplayer/img/button-bg.png CHANGED
File without changes
module/jq-mplayer/img/player-bg.png CHANGED
File without changes
module/jq-mplayer/img/player-next-hover.png CHANGED
File without changes
module/jq-mplayer/img/player-next.png CHANGED
File without changes
module/jq-mplayer/img/player-pause-hover.png CHANGED
File without changes
module/jq-mplayer/img/player-pause.png CHANGED
File without changes
module/jq-mplayer/img/player-previous-hover.png CHANGED
File without changes
module/jq-mplayer/img/player-previous.png CHANGED
File without changes
module/jq-mplayer/img/player-progress.png CHANGED
File without changes
module/jq-mplayer/img/rating-bar-on.png CHANGED
File without changes
module/jq-mplayer/img/rating-bar.png CHANGED
File without changes
module/jq-mplayer/img/rating-on.png CHANGED
File without changes
module/jq-mplayer/img/tracklist-bg.png CHANGED
File without changes
module/jq-mplayer/img/tracklist-more.png CHANGED
File without changes
module/minima/gallery.swf CHANGED
File without changes
module/minima/img/loader.gif CHANGED
File without changes
module/phantom/css/style.css CHANGED
@@ -3,421 +3,608 @@ body.gmPhantom_zoom * { -webkit-user-select:none; }
3
  .phantom_module { position:relative; }
4
  .gmPhantom_Container * { -moz-box-sizing:content-box; box-sizing:content-box; }
5
  .gmPhantom_Container {
6
- direction:ltr;
7
- margin:0;
8
- overflow:hidden;
9
- padding:0;
10
- position:relative;
11
- height:auto;
12
- z-index:0;
 
 
 
 
 
 
 
 
 
13
  }
 
 
 
 
14
  div.gmPhantom_Container img {
15
- border:medium none;
16
- margin:0;
17
- padding:0;
18
  }
19
  .gmPhantom_Background {
20
- margin:0;
21
- padding:0;
22
- position:absolute;
23
- left:0; top:0; right:0; bottom:0;
24
- z-index:100;
25
  }
26
  .gmPhantom_thumbsWrapper {
27
- background:none repeat scroll 0 0 transparent;
28
- height:auto;
29
- margin:0 auto;
30
- text-align:left;
31
- overflow:hidden;
32
- padding:0;
33
- position:relative;
34
- z-index:200;
35
  }
36
  .gmPhantom_ThumbContainer {
37
- cursor:pointer;
38
- float:left;
39
- margin:0;
40
- padding:0;
41
- position:relative;
42
- overflow:hidden;
43
- background:url(../img/ThumbnailLoader.gif) -100% -100% no-repeat;
 
 
 
 
 
 
 
 
 
44
  }
45
  .gmPhantom_ThumbContainer.gmPhantom_ThumbLoader {
46
- background-position:50% 50%;
47
  }
48
  .gmPhantom_Thumb {
49
- margin:0;
50
- overflow:hidden;
51
- padding:0;
52
- position:static;
53
- width:100%; height:100%;
54
- -webkit-transition:0.2s; transition:0.2s;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
  .gmPhantom_ThumbContainer:hover .gmPhantom_Thumb {
57
- transform:scale(1.2); -webkit-transform:scale(1.2);
 
58
  }
59
- .gmPhantom_Thumb img {
60
- border:0;
61
- margin:0;
62
- padding:0;
63
- max-height:none !important;
64
- max-width:none !important;
65
- min-height:0 !important;
66
- min-width:0 !important;
67
  }
68
- .gmPhantom_Thumb img.landscape { height:100%; width:auto; }
69
- .gmPhantom_Thumb img.portrait { height:auto; width:100%; }
 
 
 
 
 
 
 
 
 
 
 
70
  .gmPhantom_ThumbLabel {
71
- font-family:Arial, Helvetica, Verdana, sans-serif;
72
- font-size:11px;
73
- font-weight:bold;
74
- line-height:1em;
75
- padding:7px 2px;
76
- position:absolute;
77
- top:100%; left:0; right:0;
78
- color:#e7e7e7;
79
- background-color:rgba(0, 0, 0, 0.5);
80
- text-align:center;
81
- max-height:100%;
82
- overflow:hidden;
 
83
  }
84
  .gmPhantom_ThumbLabel a {
85
- font-family:Arial, Helvetica, Verdana, sans-serif;
86
- font-size:11px;
87
- font-weight:bold;
88
- line-height:1em;
89
- color:#e7e7e7;
90
- background-color:transparent;
91
- display:inline;
92
- text-decoration:none;
93
- }
94
- .gmPhantom_LightboxWrapper {
95
- display:none;
96
- left:0;
97
- top:0;
98
- bottom:0;
99
- right:0;
100
- position:fixed;
101
- width:100%; height:100%;
102
- overflow:hidden;
103
- z-index:200000;
104
- font-size:14px;
105
- -webkit-text-size-adjust:none;
106
- -webkit-backface-visibility:hidden;
107
- -webkit-transform:translateZ(0);
108
- -webkit-user-select:none;
109
- -moz-user-select:none;
110
- }
111
- .gmPhantom_Container .gmPhantom_LightboxWrapper {
112
- position:absolute;
113
- }
114
- .gmPhantom_LightboxWrapper * { -webkit-user-select:none; -moz-box-sizing:border-box; box-sizing:border-box; }
115
- .gmPhantom_bodyBg { display:none; position:absolute; left:0; top:0; bottom:0; right:0; width:100%; height:100%; z-index:150000; }
116
- .gmPhantom_LightboxWrapper.gm_show + .gmPhantom_bodyBg { display:block; }
117
- .gmPhantom_LightboxWindow {
118
- position:absolute;
119
- top:0; left:0;
120
- bottom:0; right:0;
121
- width:100%; height:100%;
122
- font-size:100%;
123
- -moz-box-sizing:border-box; box-sizing:border-box;
124
- padding:0;
125
- text-align:center;
126
- white-space:nowrap;
127
- }
128
- .gmPhantom_LightboxWindow.gmPhantom_LightboxLoader {
129
- background:url(../img/LightboxLoader.gif) 50% 50% no-repeat;
130
- }
131
- .gmPhantom_LightboxWindow > img {
132
- max-height:none !important;
133
- max-width:none !important;
134
- min-height:0 !important;
135
- min-width:0 !important;
136
- }
137
- .fix_window { position:absolute; right:0; bottom:0; width:1px; height:1px; overflow:hidden; }
138
- .gmPhantom_LightboxContainer {
139
- opacity:0;
140
- position:relative;
141
- left:0; top:0;
142
- display:inline-block;
143
- text-align:left;
144
- vertical-align:middle;
145
- margin:0 auto;
146
- z-index:100;
147
- }
148
- .gmPhantom_LightboxContainer:before {
149
- position:absolute;
150
- left:0; top:-1000px;
151
- width:100%;
152
- height:2000px;
153
- content:'';
154
- }
155
- .gmPhantom_LightboxBg {
156
- position:absolute;
157
- left:0; top:0; right:0; bottom:0;
158
- }
159
- .gmPhantom_Lightbox {
160
- position:relative;
161
- display:block;
162
- height:100%;
163
- width:100%;
164
- overflow:visible;
165
- }
166
- .gmPhantom_Lightbox img {
167
- display:inline-block;
168
- vertical-align:middle;
169
- max-width:100%; max-height:100%;
170
- }
171
- .gmlog {
172
- text-align:left;
173
- color:#ffffff;
174
- font-size:20px;
175
- padding:0; margin:0;
176
- }
177
- .gmPhantom_LightboxNav_PrevBtn {
178
- position:absolute;
179
- left:0; top:0;
180
- cursor:pointer;
181
- width:20%;
182
- height:100%;
183
- overflow:hidden;
184
- z-index:49;
185
- }
186
- .gmPhantom_LightboxNav_NextBtn {
187
- position:absolute;
188
- right:0; top:0;
189
- cursor:pointer;
190
- width:20%;
191
- height:100%;
192
- overflow:hidden;
193
- z-index:50;
194
- }
195
- .gmPhantom_LightboxNav_PrevBtn.gm_lbw_nav,
196
- .gmPhantom_LightboxNav_NextBtn.gm_lbw_nav { width:50%; }
197
- .gmPhantom_LightboxNav_PrevBtn span,
198
- .gmPhantom_LightboxNav_NextBtn span {
199
- position:absolute;
200
- top:50%;
201
- margin-top:-1.5em;
202
- cursor:pointer;
203
- height:3em;
204
- line-height:2.8em;
205
- font-size:4em;
206
- font-family:Arial, serif;
207
- padding:0 0.16em;
208
- color:#cccccc;
209
- border:1px solid #bababa;
210
- background-color:#010101;
211
- opacity:0.4;
212
- }
213
- .gmPhantom_LightboxNav_PrevBtn span { left:0; border-left:none; }
214
- .gmPhantom_LightboxNav_NextBtn span { right:0; border-right:none; }
215
- .gmPhantom_counter {
216
- position:absolute;
217
- z-index:100;
218
- right:0; bottom:0;
219
- white-space:nowrap; padding:0.1em 0.6em; line-height:100%;
220
- font:1.2em Arial;
221
- color:#cccccc;
222
- border:1px solid #bababa;
223
- border-width:1px 0 0 1px;
224
- background-color:#010101;
225
- }
226
- .gmPhantom_counter:hover {
227
- color:#fefefe;
228
- }
229
- .gmPhantom_info {
230
- display:none;
231
- position:absolute;
232
- z-index:20;
233
- left:0; bottom:0;
234
- padding:0.1em 0.3em; line-height:100%;
235
- font:1.6em 'Times New Roman';
236
- color:#cccccc;
237
- }
238
- .gmPhantom_LightboxNavExtraButtons {
239
- position:absolute;
240
- left:0; top:0;
241
- width:100%;
242
- height:1px;
243
- overflow:visible;
244
- z-index:110;
245
- text-align:center;
246
- }
247
- .gmPhantom_LightboxNav_CloseBtn {
248
- position:relative;
249
- float:right;
250
- text-align:center;
251
- }
252
- .gmPhantom_LightboxNav_CloseBtn span {
253
- display:block;
254
- cursor:pointer;
255
- color:#cccccc;
256
- border:1px solid #bababa;
257
- border-width:0 0 1px 1px;
258
- background-color:#010101;
259
- line-height:2em;
260
- height:2em;
261
- font-size:1.2em;
262
- font-family:Arial, sans-serif;
263
- padding:0 1.2em;
264
- }
265
- .gmPhantom_LightboxNav_CloseBtn span:hover,
266
- .gmPhantom_LightboxNav_CloseBtn span:active {
267
- color:#fefefe;
268
- }
269
- .gmPhantom_LightboxSocialShare {
270
- position:relative;
271
- float:left;
272
- text-align:center;
273
- }
274
- .gmPhantom_LightboxSocialShare .gmAddThisShareButton > a,
275
- .gmPhantom_LightboxSocialShare .gmAddThisShareButton > a:hover {
276
- display:block; line-height:2em; height:2em;
277
- cursor:pointer;
278
- font-size:1.2em;
279
- font-family:Arial, sans-serif;
280
- color:#cccccc;
281
- border:1px solid #bababa;
282
- border-width:0 1px 1px 0;
283
- background-color:#010101;
284
- text-decoration:none;
285
- padding:0 1.2em;
286
- }
287
- .gmPhantom_LightboxSocialShare .gmAddThisShareButton > a:hover,
288
- .gmPhantom_LightboxSocialShare .gmAddThisShareButton > a:active {
289
- color:#fefefe;
290
- }
291
- .gmPhantom_CaptionTitle {
292
- color:#ffffff;
293
- font-family:Arial, Helvetica, Verdana, sans-serif;
294
- font-size:1em;
295
- font-weight:bold;
296
- line-height:100%;
297
- margin:0; padding:0;
298
- position:absolute;
299
- left:0; top:0; width:100%;
300
- background-color:rgba(0, 0, 0, 0.5);
301
- display:none;
302
- white-space:normal;
303
- }
304
- .gmPhantom_CaptionTitle .gmPhantom_title {
305
- padding:0.8em;
306
- }
307
- .gmPhantom_CaptionTextContainer {
308
- margin:0; padding:0;
309
- overflow:auto;
310
- position:absolute;
311
- left:0; bottom:0;
312
- max-height:50%;
313
- width:100%;
314
- background-color:rgba(0, 0, 0, 0.5);
315
- display:none;
316
- white-space:normal;
317
- }
318
- .gmPhantom_CaptionText {
319
- color:#ffffff;
320
- font-family:Arial, Helvetica, Verdana, sans-serif;
321
- font-size:0.9em;
322
- line-height:120%;
323
- position:relative;
324
- padding:0.8em;
325
- }
326
  .gmPhantom_Tooltip {
327
- border-radius:3px;
328
- border:1px solid #000000;
329
- display:none;
330
- font-family:Arial, Helvetica, Verdana, sans-serif;
331
- font-size:11px;
332
- font-weight:normal;
333
- line-height:1.5em;
334
- padding:0 5px 1px;
335
- position:absolute;
336
- text-align:center;
337
- text-transform:none;
338
- z-index:300;
339
- pointer-events:none;
340
  }
341
  .gmPhantom_Tooltip div.gmPhantom_Tooltip_ArrowBorder {
342
- border-color:#000000 transparent transparent;
343
- border-style:solid;
344
- border-width:5px;
345
- bottom:-10px;
346
- height:0;
347
- position:absolute;
348
- width:0;
349
  }
350
  .gmPhantom_Tooltip div.gmPhantom_Tooltip_Arrow {
351
- border-color:#ffffff transparent transparent;
352
- border-style:solid;
353
- border-width:5px;
354
- bottom:-9px;
355
- height:0;
356
- position:absolute;
357
- width:0;
358
- }
359
- .msie .gmPhantom_CaptionTitle,
360
- .msie .gmPhantom_CaptionTextContainer,
361
- .msie .gmPhantom_ThumbLabel { background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAYAAAD0In+KAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QkFEQ0Y1MjQ1QTg4MTFFMkFCRjFCRDZEQjFDMTJDNDciIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QkFEQ0Y1MjU1QTg4MTFFMkFCRjFCRDZEQjFDMTJDNDciPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpCQURDRjUyMjVBODgxMUUyQUJGMUJENkRCMUMxMkM0NyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpCQURDRjUyMzVBODgxMUUyQUJGMUJENkRCMUMxMkM0NyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pj9rBBcAAAASSURBVHjaYmRgYNgMxAwAAQYAA5EAtcchicsAAAAASUVORK5CYII='); }
362
- .msie7 .gmPhantom_LightboxContainer { display:inline; }
363
- #at15s {
364
- position:fixed !important;
365
- }
366
- /* for touch devices */
367
- .istouch .gmPhantom_LightboxContainer:before {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  display:none;
369
- }
370
- .istouch .gmPhantom_LightboxContainer { z-index:auto; }
371
- .istouch .gmPhantom_LightboxNav_PrevBtn,
372
- .istouch .gmPhantom_LightboxNav_NextBtn { display:none; }
373
- .istouch .gmPhantom_LightboxContainer .gmPhantom_LightboxNav_PrevBtn,
374
- .istouch .gmPhantom_LightboxContainer .gmPhantom_LightboxNav_NextBtn { display:inline-block; width:0; background:url(../img/LightboxLoader.gif) 50% 50% no-repeat; background-size:30% auto; }
375
- .istouch .gmPhantom_LightboxNavExtraButtons { position:static; }
376
- .istouch .gmPhantom_LightboxNav_CloseBtn {
377
- position:absolute; bottom:0; left:0; width:100%; opacity:0.5;
378
- }
379
- .istouch .gmPhantom_LightboxNav_CloseBtn span {
380
- border-width:1px 1px 0 1px; display:inline-block; margin:0 auto;
381
- }
382
- .istouch .gmPhantom_LightboxNav_CloseBtn.hover { opacity:0.9; }
383
- .istouch .gmPhantom_LightboxNav_CloseBtn.hover span { border-color:red; background-color:green; }
384
- .istouch .gmPhantom_LightboxSocialShare {
385
- position:absolute; top:0; left:0; width:100%; opacity:0.5;
386
- }
387
- .istouch .gmPhantom_LightboxSocialShare .gmAddThisShareButton > a {
388
- border-width:0 1px 1px 1px; display:inline-block; margin:0 auto;
389
- }
390
- .istouch .gmPhantom_LightboxSocialShare.hover { opacity:0.9; }
391
- .istouch .gmPhantom_LightboxSocialShare.hover .gmAddThisShareButton > a { border-color:red; background-color:green; }
392
- .istouch .gmPhantom_CaptionTitle { top:auto; bottom:50%; font-size:1.2em }
393
- .istouch .gmPhantom_CaptionTextContainer { bottom:auto; top:50%; max-height:none; }
394
- .istouch .gmPhantom_CaptionText { font-size:1.1em }
395
- .gmPhantom_Container.delay {
396
  opacity:0;
397
- -moz-animation:slide 1s ease 1s forwards;
398
- -webkit-animation:slide 1s ease 1s forwards;
399
- -o-animation:slide 1s ease 1s forwards;
400
- -ms-animation:slide 1s ease 1s forwards;
401
- animation:slide 1s ease 1s forwards;
402
- }
403
- @-moz-keyframes slide {
404
- from { opacity:0; }
405
- to { opacity:1; }
406
- }
407
- @-webkit-keyframes slide {
408
- from { opacity:0; }
409
- to { opacity:1; }
410
- }
411
- @-o-keyframes slide {
412
- from { opacity:0; }
413
- to { opacity:1; }
414
- }
415
- @-ms-keyframes slide {
416
- from { opacity:0; }
417
- to { opacity:1; }
418
- }
419
- @keyframes slide {
420
- from { opacity:0; }
421
- to { opacity:1; }
 
 
422
  }
423
- body .gmShowBuster { display:block !important; }
3
  .phantom_module { position:relative; }
4
  .gmPhantom_Container * { -moz-box-sizing:content-box; box-sizing:content-box; }
5
  .gmPhantom_Container {
6
+ direction:ltr;
7
+ margin:0;
8
+ overflow:hidden;
9
+ padding:0;
10
+ position:relative;
11
+ height:auto;
12
+ z-index:0;
13
+ opacity:1;
14
+ -moz-transition:opacity 1s;
15
+ -webkit-transition:opacity 1s;
16
+ -o-transition:opacity 1s;
17
+ -ms-transition:opacity 1s;
18
+ transition:opacity 1s;
19
+ -webkit-transform:translateZ(0);
20
+ -moz-transform:translateZ(0);
21
+ transform:translateZ(0);
22
  }
23
+ .gmPhantom_Container.delay {
24
+ opacity:0;
25
+ }
26
+
27
  div.gmPhantom_Container img {
28
+ border:medium none;
29
+ margin:0;
30
+ padding:0;
31
  }
32
  .gmPhantom_Background {
33
+ margin:0;
34
+ padding:0;
35
+ position:absolute;
36
+ left:0; top:0; right:0; bottom:0;
37
+ z-index:100;
38
  }
39
  .gmPhantom_thumbsWrapper {
40
+ background:none repeat scroll 0 0 transparent;
41
+ height:auto;
42
+ margin:0 auto;
43
+ text-align:left;
44
+ overflow:hidden;
45
+ padding:0;
46
+ position:relative;
47
+ z-index:200;
48
  }
49
  .gmPhantom_ThumbContainer {
50
+ cursor:pointer;
51
+ float:left;
52
+ margin:0;
53
+ padding:5px;
54
+ width:160px;
55
+ height:120px;
56
+ position:relative;
57
+ border: 1px solid #cccccc;
58
+ background-color:#ffffff;
59
+ box-shadow: 0 0 5px -2px;
60
+ overflow:hidden;
61
+ background:url(../img/loader.gif) -100% -100% no-repeat;
62
+ }
63
+ .gmPhantom_MobileView .gmPhantom_ThumbContainer {
64
+ width:96px;
65
+ height:72px;
66
  }
67
  .gmPhantom_ThumbContainer.gmPhantom_ThumbLoader {
68
+ background-position:50% 50%;
69
  }
70
  .gmPhantom_Thumb {
71
+ display:block;
72
+ outline:none;
73
+ margin:0;
74
+ overflow:hidden;
75
+ padding:0;
76
+ position:static;
77
+ width:100%; height:100%;
78
+ -webkit-transition:0.2s; transition:0.2s;
79
+ -webkit-transition-property: all !important;
80
+ transition-property: all !important;
81
+ opacity:0.85;
82
+ filter: alpha(opacity=85);
83
+ }
84
+ .gmPhantom_Thumb:hover, .gmPhantom_Thumb:active {
85
+ display:block;
86
+ outline:none;
87
+ margin:0;
88
+ overflow:hidden;
89
+ padding:0;
90
+ position:static;
91
+ width:100%; height:100%;
92
  }
93
  .gmPhantom_ThumbContainer:hover .gmPhantom_Thumb {
94
+ opacity:1;
95
+ filter:alpha(opacity=100);
96
  }
97
+ .gmPhantom_ThumbScale .gmPhantom_ThumbContainer:hover .gmPhantom_Thumb {
98
+ transform:scale(1.2) translateZ(0); -webkit-transform:scale(1.2) translateZ(0);
 
 
 
 
 
 
99
  }
100
+ .gmPhantom_Thumb img {
101
+ position:relative;
102
+ display:block;
103
+ border:0;
104
+ margin:0;
105
+ padding:0;
106
+ max-height:none !important;
107
+ max-width:none !important;
108
+ min-height:0 !important;
109
+ min-width:0 !important;
110
+ }
111
+ .gmPhantom_Thumb img.landscape { height:100% !important; width:auto !important; }
112
+ .gmPhantom_Thumb img.portrait { height:auto !important; width:100% !important; }
113
  .gmPhantom_ThumbLabel {
114
+ font-family:Arial, Helvetica, Verdana, sans-serif;
115
+ font-size:11px;
116
+ font-weight:bold;
117
+ line-height:1em;
118
+ padding:7px 2px;
119
+ position:absolute;
120
+ bottom:0; left:0; right:0;
121
+ color:#0b0b0b;
122
+ background-color:#ffffff;
123
+ text-align:center;
124
+ max-height:100%;
125
+ overflow:hidden;
126
+ -webkit-transition:0.2s; transition:0.2s;
127
  }
128
  .gmPhantom_ThumbLabel a {
129
+ font-family:Arial, Helvetica, Verdana, sans-serif;
130
+ font-size:11px;
131
+ font-weight:bold;
132
+ line-height:1em;
133
+ color:#3695E7;
134
+ background-color:transparent;
135
+ display:inline;
136
+ }
137
+ .gmPhantom_LabelTolltip .gmPhantom_ThumbLabel,
138
+ .gmPhantom_LabelNone .gmPhantom_ThumbLabel {display:none;}
139
+ .gmPhantom_LabelInside .gmPhantom_ThumbLabel,
140
+ .gmPhantom_LabelHover .gmPhantom_ThumbLabel {margin-bottom:-36px; color:#e7e7e7; background-color:rgba(0, 0, 0, 0.5);}
141
+ .gmPhantom_LabelHover .gmPhantom_ThumbLabel a {color:#e7e179;}
142
+ .gmPhantom_LabelInside .gmPhantom_ThumbLabel,
143
+ .gmPhantom_LabelHover .gmPhantom_ThumbContainer:hover .gmPhantom_ThumbLabel {margin-bottom:10px;}
144
+
145
+ .gmPhantom_LabelBottom .gmPhantom_ThumbContainer {padding-bottom: 36px;}
146
+ .gmPhantom_LabelBottom .gmPhantom_ThumbLabel {background-color:#ffffff;}
147
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  .gmPhantom_Tooltip {
149
+ border-radius:3px;
150
+ border:1px solid #000000;
151
+ display:none;
152
+ font-family:Arial, Helvetica, Verdana, sans-serif;
153
+ font-size:11px;
154
+ font-weight:normal;
155
+ line-height:1.5em;
156
+ padding:0 5px 1px;
157
+ position:absolute;
158
+ text-align:center;
159
+ text-transform:none;
160
+ z-index:300;
161
+ pointer-events:none;
162
  }
163
  .gmPhantom_Tooltip div.gmPhantom_Tooltip_ArrowBorder {
164
+ border-color:#000000 transparent transparent;
165
+ border-style:solid;
166
+ border-width:5px;
167
+ bottom:-10px;
168
+ height:0;
169
+ position:absolute;
170
+ width:0;
171
  }
172
  .gmPhantom_Tooltip div.gmPhantom_Tooltip_Arrow {
173
+ border-color:#ffffff transparent transparent;
174
+ border-style:solid;
175
+ border-width:5px;
176
+ bottom:-9px;
177
+ height:0;
178
+ position:absolute;
179
+ width:0;
180
+ }
181
+ body .gmShowBuster { display:block !important; }
182
+
183
+
184
+
185
+ /******* Custom MFP CSS *******/
186
+
187
+ /* zoom-in animation on open */
188
+ .mfp-ready .mfp-figure {
189
+ opacity:0;
190
+ filter: alpha(opacity=0);
191
+ }
192
+ .mfp-zoom-in {
193
+ /* start state */
194
+ /* animate in */
195
+ /* animate out */
196
+ }
197
+ .mfp-zoom-in.mfp-bg,
198
+ .mfp-zoom-in .mfp-preloader,
199
+ .mfp-zoom-in .mfp-figure,
200
+ .mfp-zoom-in .mfp-iframe-wrapper,
201
+ .mfp-zoom-in button,
202
+ .mfp-zoom-in .mfp-button,
203
+ .mfp-zoom-in .mfp-gmedia-stuff08,
204
+ .mfp-zoom-in .mfp-gmedia-stuff10 {
205
+ opacity:0;
206
+ filter: alpha(opacity=0);
207
+ -webkit-backface-visibility:hidden;
208
+ /* ideally, transition speed should match zoom duration */
209
+ -webkit-transition:all 0.3s ease-out;
210
+ -moz-transition:all 0.3s ease-out;
211
+ -o-transition:all 0.3s ease-out;
212
+ transition:all 0.3s ease-out;
213
+ }
214
+ .mfp-zoom-in .mfp-figure {
215
+ transform:scale(0.9) translateZ(0);
216
+ }
217
+
218
+ .mfp-zoom-in.mfp-ready.mfp-bg,
219
+ .mfp-zoom-in.mfp-ready button,
220
+ .mfp-zoom-in.mfp-ready .mfp-button,
221
+ .mfp-zoom-in.mfp-ready .mfp-gmedia-stuff08 {
222
+ opacity:0.8;
223
+ filter: alpha(opacity=80);
224
+ }
225
+
226
+ .mfp-zoom-in.mfp-image-loaded .mfp-figure,
227
+ .mfp-zoom-in.mfp-iframe-loaded .mfp-iframe-wrapper ,
228
+ .mfp-zoom-in.mfp-ready .mfp-gmedia-stuff10 {
229
+ opacity:1;
230
+ filter: alpha(opacity=100);
231
+ }
232
+ .mfp-zoom-in.mfp-image-loaded .mfp-figure {
233
+ opacity:1;
234
+ filter: alpha(opacity=100);
235
+ transform:scale(1) translateZ(0);
236
+ }
237
+
238
+ .mfp-zoom-in.mfp-removing.mfp-bg,
239
+ .mfp-zoom-in.mfp-removing .mfp-preloader,
240
+ .mfp-zoom-in.mfp-removing .mfp-figure,
241
+ .mfp-zoom-in.mfp-removing .mfp-iframe-wrapper,
242
+ .mfp-zoom-in.mfp-removing .mfp-comments-container,
243
+ .mfp-zoom-in.mfp-removing button,
244
+ .mfp-zoom-in.mfp-removing .mfp-button,
245
+ .mfp-zoom-in.mfp-removing .mfp-gmedia-stuff08,
246
+ .mfp-zoom-in.mfp-removing .mfp-gmedia-stuff10 {
247
+ opacity:0;
248
+ filter: alpha(opacity=0);
249
+ }
250
+ .mfp-zoom-in.mfp-removing .mfp-figure {
251
+ transform:scale(0.9);
252
+ }
253
+
254
+ .mfp-button:not(.mfp-close) {
255
+ cursor:pointer;
256
+ }
257
+ .mfp-zoom-in button:hover,
258
+ .mfp-zoom-in button:focus,
259
+ .mfp-zoom-in .mfp-button:hover,
260
+ .mfp-zoom-in .mfp-button:focus,
261
+ .mfp-button.mfp-gmedia-stuff08:hover,
262
+ .mfp-button.mfp-gmedia-stuff08:focus {
263
+ opacity:1;
264
+ filter: alpha(opacity=100);
265
+ }
266
+
267
+
268
+ /* CSS-based preloader */
269
+ .mfp-preloader {
270
+ width:30px !important;
271
+ height:30px;
272
+ background-color:#ffffff;
273
+ opacity:0.65;
274
+ filter: alpha(opacity=65);
275
+ margin:0 auto;
276
+ animation:rotateplane 1.2s infinite ease-in-out;
277
+ }
278
+ @keyframes rotateplane {
279
+ 0% {
280
+ transform:perspective(120px) rotateX(0deg) rotateY(0deg) translateZ(0);
281
+ }
282
+ 50% {
283
+ transform:perspective(120px) rotateX(-180.1deg) rotateY(0deg) translateZ(0);
284
+ }
285
+ 100% {
286
+ transform:perspective(120px) rotateX(-180deg) rotateY(-179.9deg) translateZ(0);
287
+ }
288
+ }
289
+
290
+
291
+
292
+ .mfp-bg {
293
+ top:-10%;
294
+ bottom:-100%;
295
+ right:-100%;
296
+ height:auto;
297
+ width:auto;
298
+ }
299
+ .mfp-bg, .mfp-wrap {
300
+ z-index:99999;
301
+ -webkit-overflow-scrolling: touch;
302
+ -webkit-transform: translateZ(0);
303
+ -moz-transform: translateZ(0);
304
+ transform: translateZ(0);
305
+ }
306
+ .mfp-close.mfp-button, .mfp-arrow, .mfp-preloader {
307
+ position:fixed;
308
+ }
309
+ .mfp-close.mfp-button, .mfp-arrow {
310
+ overflow:visible;
311
+ z-index:1046;
312
+ }
313
+ .mfp-close.mfp-button {
314
+ right: auto;
315
+ left: 0;
316
+ padding-right: 10px;
317
+ padding-left: 0;
318
+ }
319
+ .mfp-arrow {
320
+ bottom: 50%;
321
+ top: auto;
322
+ margin-top:auto;
323
+ margin-bottom:-55px;
324
+ }
325
+ .mfp-figure figure {
326
+ min-width:308px;
327
+ }
328
+ img.mfp-img,
329
+ img.mfp-img--comments-div {
330
+ width: auto;
331
+ max-width: 100%;
332
+ height: auto;
333
+ display: block;
334
+ line-height: 0;
335
+ -webkit-box-sizing: border-box;
336
+ -moz-box-sizing: border-box;
337
+ box-sizing: border-box;
338
+ padding: 40px 0 40px;
339
+ margin: 0 auto;
340
+ }
341
+ .mfp-prevent-click { pointer-events:none; }
342
+
343
+ .mfp-title { font-weight:bold; font-size:larger; }
344
+ .mfp-counter { color:#f3f3f3; opacity:0.9; filter: alpha(opacity=90); }
345
+ .mfp-description {
346
+ text-align:left;
347
+ line-height:130%;
348
+ color:#f3f3f3;
349
+ word-wrap:break-word;
350
+ padding:0;
351
+ margin:10px 0;
352
+ opacity:1;
353
+ filter: alpha(opacity=100);
354
+ min-width:250px;
355
+ transition:opacity 0.6s, height 0.6s;
356
+ -webkit-transition:opacity 0.3s, height 0.6s;
357
+ }
358
+
359
+ .mfp-buttons-bar {
360
+ -webkit-user-select:none;
361
+ -moz-user-select:none;
362
+ user-select:none;
363
+ -webkit-appearance:none;
364
+ z-index:1046;
365
+ position:fixed;
366
+ right:0;
367
+ top:0;
368
+ padding:10px;
369
+ color:#ffffff;
370
+ font-style:normal;
371
+ font-size:20px;
372
+ font-family:Arial, Baskerville, monospace;
373
+ transform:translateZ(0);
374
+ }
375
+ .mfp-buttons-bar .mfp-button {
376
+ display:inline-block;
377
+ margin-left:25px;
378
+ }
379
+ .mfp-share {
380
+ cursor:pointer;
381
+ display:block;
382
+ position:relative;
383
+ text-align:center;
384
+ opacity:0.65;
385
+ filter:alpha(opacity=65);
386
+ }
387
+ .mfp-zoom-in.mfp-ready .mfp-share_open.mfp-share {
388
+ opacity:1;
389
+ filter:alpha(opacity=100); }
390
+ .mfp-share:active > a {
391
+ top:1px; }
392
+
393
+ .mfp-comments-open .mfp-description {
394
+ opacity:0;
395
+ filter: alpha(opacity=0);
396
+ height:0;
397
+ margin:0;
398
+ overflow:hidden;
399
+ }
400
+
401
+ .mfp-share_sharelizers { position:absolute; right:100%; top:0; display:block; margin:0; padding:0; list-style:none; white-space:nowrap; overflow:hidden; pointer-events:none;
402
+ transition:padding 0.2s ease-in-out; -webkit-transition:padding 0.2s ease-in-out;}
403
+ .mfp-share_open .mfp-share_sharelizers { pointer-events:auto; padding:0 5px; }
404
+ .mfp-share_sharelizers li { list-style:none; margin:0; padding:0; display:inline-block; position:relative; left:100%;
405
+ transition:left 0.2s ease-in-out; -webkit-transition:left 0.2s ease-in-out;}
406
+ .mfp-share_open .mfp-share_sharelizers li { left:0; }
407
+ .mfp-share_sharelizer { box-sizing:content-box; padding:1px; display:inline-block; text-decoration:none; border-radius:3px; border:none; cursor:pointer; -webkit-box-shadow:rgba(255, 255, 255, 0.0980392) 0 1px 0 inset; box-shadow:rgba(255, 255, 255, 0.0980392) 0 1px 0 inset; line-height:100%; width:1em; height:1em; text-indent:-9999px; overflow:hidden; background:50% 50% no-repeat rgba(255, 255, 255, 0.14902);
408
+ transition:background-color 0.2s ease-in-out; -webkit-transition:background-color 0.2s ease-in-out;}
409
+ .mfp-share_facebook { background-image:url('../img/facebook@2x.png'); background-size:1em 1em; }
410
+ .mfp-share_facebook:hover { background-color:#3b5998; }
411
+ .mfp-share_twitter { background-image:url('../img/twitter@2x.png'); background-size:1em 1em; }
412
+ .mfp-share_twitter:hover { background-color:#00aced; }
413
+ .mfp-share_pinterest { background-image:url('../img/pinterest@2x.png'); background-size:1em 1em; }
414
+ .mfp-share_pinterest:hover { background-color:#cc2127; }
415
+ .mfp-share_google { background-image:url('../img/google@2x.png'); background-size:1em 1em; }
416
+ .mfp-share_google:hover { background-color:#d64a2d; }
417
+ .mfp-share_stumbleupon { background-image:url('../img/stumbleupon@2x.png'); background-size:1em 1em; }
418
+ .mfp-share_stumbleupon:hover { background-color:#ea4b24; }
419
+
420
+ @media screen and (max-width:800px) and (orientation:landscape), screen and (max-height:300px) {
421
+ .mfp-img-mobile .mfp-buttons-bar {
422
+ padding:8px;
423
+ }
424
+ }
425
+
426
+ .mfp-comments,
427
+ .mfp-likes,
428
+ .mfp-views {
429
+ cursor:pointer;
430
+ display:inline-block;
431
+ text-align:center;
432
+ opacity:0.65;
433
+ filter:alpha(opacity=65);
434
+ }
435
+ .mfp-comments-count,
436
+ .mfp-likes-count,
437
+ .mfp-views-count {
438
+ font-size:0.8em;
439
+ }
440
+ .phantom-gmedia-liked .mfp_likes_icon {
441
+ color:red;
442
+ }
443
+
444
+ .mfp-button > span,
445
+ .mfp-button > a,
446
+ .mfp-button > a:hover { display:block; position:relative; color:inherit !important; text-decoration:none !important; outline:none; }
447
+ .mfp-button > span *,
448
+ .mfp-button > a * { display:inline-block; }
449
+ .mfp-button svg {
450
+ display:block;
451
+ width:1em;
452
+ height:1em;
453
+ fill:currentColor;
454
+ }
455
+
456
+ .mfp-container {
457
+ bottom:0;
458
+ height:auto;
459
+ }
460
+ .mfp-content {
461
+ min-height:0;
462
+ max-height:100%;
463
+ padding:0;
464
+ transition:padding 0.6s, min-height 0.6s;
465
+ -webkit-transition:padding 0.6s, min-height 0.6s;
466
+ box-sizing:border-box;
467
+ }
468
+ .mfp-iframe-holder {
469
+ padding-top:0;
470
+ padding-bottom:0;
471
+ }
472
+ .mfp-iframe-wrapper {
473
+ position:relative;
474
+ padding-bottom:40px;
475
+ padding-top:40px;
476
+ }
477
+ .mfp-iframe-scaler {
478
+ position:relative;
479
+ box-shadow:0 0 8px rgba(0, 0, 0, 0.6);
480
+ }
481
+ [data-gmtype="audio"] .mfp-iframe-scaler {
482
+ padding-top:25%
483
+ }
484
+ [data-gmtype="application"] .mfp-iframe-scaler {
485
+ padding-top:25%
486
+ }
487
+ [data-ext="pdf"] .mfp-iframe-scaler {
488
+ padding-top:56.25%
489
+ }
490
+ .mfp-iframe-scaler iframe {
491
+ box-shadow:none;
492
+ background-color:rgba(0, 0, 0, 0.5);
493
+ }
494
+
495
+ .mfp-comments-container {
496
+ position:absolute;
497
+ right:0;
498
+ top:0;
499
+ height:100%;
500
+ width:0;
501
+ opacity:0;
502
+ filter: alpha(opacity=0);
503
+ overflow:hidden;
504
+ box-sizing:border-box;
505
+ padding:40px 0;
506
+ margin:0;
507
+ transition:width 0.6s, height 0.6s, opacity 0.3s;
508
+ -webkit-transition:width 0.6s, height 0.6s, opacity 0.3s;
509
+ }
510
+ .mfp-comments-container * {
511
+ box-sizing:border-box;
512
+ }
513
+ .mfp-comments-content {
514
+ position:relative;
515
+ padding:0 30px 0 0;
516
+ box-sizing:content-box;
517
+ height:100%;
518
+ width:100%;
519
+ min-width:320px;
520
+ background-color:rgba(255, 255, 255, 0.8);
521
+ overflow:hidden;
522
+ overflow-y:auto;
523
+ }
524
+ .mfp-comments-wrapper {
525
+ width:100%;
526
+ }
527
+ .mfp-comments-content iframe {
528
+ height:100%;
529
+ width:100%;
530
+ margin:0;
531
+ padding:0;
532
+ border:none;
533
+ box-shadow:none;
534
+ min-height:100%;
535
+ transition:opacity 0.4s;
536
+ -webkit-transition:opacity 0.4s;
537
+ }
538
+ .mfp-comments-open .mfp-container,
539
+ .mfp-comments-open .mfp-container:before {
540
+ transition:height 0.6s;
541
+ -webkit-transition:height 0.6s;
542
+ }
543
+ .mfp-comments-open .mfp-container:before {
544
+ height:0;
545
+ }
546
+ .mfp-comments-open .mfp-content {
547
+ padding:0 330px 20% 0;
548
+ min-height:100%;
549
+ }
550
+ .mfp-comments-open .mfp-comments-container {
551
+ width:320px;
552
+ overflow-y:visible;
553
+ opacity:1;
554
+ filter: alpha(opacity=100);
555
+ }
556
+ .mfp-zoom-in.mfp-comments-open .mfp-arrow {
557
+ opacity:0;
558
+ filter: alpha(opacity=0);
559
+ pointer-events:none;
560
+ -webkit-pointer-events:none;
561
+ }
562
+ .mfp-comments-loading .mfp-comments-container {
563
+ background-image:url(../img/loader.gif);
564
+ background-repeat:no-repeat;
565
+ background-position:50% 50%;
566
+ }
567
+ .mfp-comments-loading .mfp-comments-content iframe {
568
+ opacity:0;
569
+ filter: alpha(opacity=0);
570
+ }
571
+ .mfp-comments-loaded .mfp-comments-content iframe {
572
+ opacity:1;
573
+ filter: alpha(opacity=100);
574
+ }
575
+
576
+
577
+ @media screen and (max-width:800px) {
578
+ .mfp-buttons-bar .mfp-button.mfp-share {
579
  display:none;
580
+ }
581
+ .mfp800-hide-arrows .mfp-arrow {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
582
  opacity:0;
583
+ visibiliy:hidden;
584
+ }
585
+ .mfp-comments-open .mfp-content {
586
+ padding-right:0;
587
+ }
588
+ .mfp-comments-wrapper {
589
+ height:0;
590
+ overflow:hidden;
591
+ transition:height 0.3s;
592
+ -webkit-transition:height 0.3s;
593
+ }
594
+ .mfp-comments-open .mfp-comments-wrapper {
595
+ height:240px;
596
+ }
597
+ .mfp-comments-container {
598
+ min-width:308px;
599
+ padding:0;
600
+ width:100%;
601
+ position:relative;
602
+ transition:margin 0.6s, opacity 0.3s;
603
+ -webkit-transition:margin 0.6s, opacity 0.3s;
604
+ }
605
+ .mfp-comments-open .mfp-comments-container {
606
+ margin-top:-5px;
607
+ width:100%;
608
+ height:auto;
609
+ }
610
  }
 
module/phantom/img/LightboxLoader.gif DELETED
Binary file
module/phantom/img/ThumbnailLoader.gif DELETED
Binary file
module/phantom/img/facebook@2x.png ADDED
Binary file
module/phantom/img/google@2x.png ADDED
Binary file
module/phantom/img/loader.gif ADDED
Binary file
module/phantom/img/pinterest@2x.png ADDED
Binary file
module/phantom/img/stumbleupon@2x.png ADDED
Binary file
module/phantom/img/twitter@2x.png ADDED
Binary file
module/phantom/index.php CHANGED
@@ -3,18 +3,18 @@ $module_info = array(
3
  'base' => 'phantom',
4
  'name' => 'phantom',
5
  'title' => 'Phantom',
6
- 'version' => '2.8',
7
  'author' => 'CodEasily.com',
8
  'description' => 'This module will help you to easily add a grid gallery to your WordPress website or blog. The gallery is completely customizable, resizable and is compatible with all browsers and devices (iPhone, iPad and Android smartphones).
9
 
10
- Responsive layout | AddThis Social Sharing integrated | Unlimited number of galleries into your WordPress website | Display in a gallery an unlimited amount of images | Customize each gallery individually | Completely customizable lightbox | Design your own navigation buttons and use them | Display items at random | Browse the gallery using the mouse or a scroll | Browse the gallery on touchscreen devices using one finger (swipe thumbnails or lightbox) | Completely resizable | Change thumbnail size, border, spacing, transparency, background ...
11
  ',
12
  'type' => 'gallery',
13
  'status' => 'free',
14
  'price' => '0',
15
  'demo' => 'http://codeasily.com/portfolio-item/gmedia-phantom/',
16
  'download' => 'http://codeasily.com/download/phantom-module-zip/',
17
- 'dependencies' => ''
18
  );
19
  if (isset($_GET['info'])) {
20
  echo '<pre>' . print_r($module_info, true) . '</pre>';
3
  'base' => 'phantom',
4
  'name' => 'phantom',
5
  'title' => 'Phantom',
6
+ 'version' => '3.3',
7
  'author' => 'CodEasily.com',
8
  'description' => 'This module will help you to easily add a grid gallery to your WordPress website or blog. The gallery is completely customizable, resizable and is compatible with all browsers and devices (iPhone, iPad and Android smartphones).
9
 
10
+ Responsive | Social Sharing integrated | Views/Likes Counters Support | Comments Support | Customize each gallery individually | Customizable lightbox | Deeplinking support | Change thumbnail size, border, spacing, transparency, background, controls ...
11
  ',
12
  'type' => 'gallery',
13
  'status' => 'free',
14
  'price' => '0',
15
  'demo' => 'http://codeasily.com/portfolio-item/gmedia-phantom/',
16
  'download' => 'http://codeasily.com/download/phantom-module-zip/',
17
+ 'dependencies' => 'magnific-popup'
18
  );
19
  if (isset($_GET['info'])) {
20
  echo '<pre>' . print_r($module_info, true) . '</pre>';
module/phantom/init.php CHANGED
@@ -9,98 +9,283 @@
9
  * @var $gmedia
10
  * @var $is_bot
11
  **/
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  $content = array();
13
- if (! isset($is_bot)) {
14
  $is_bot = false;
15
  }
16
- if (! isset($shortcode_raw)) {
17
  $shortcode_raw = false;
18
  }
19
  $tab = sanitize_title($gallery['name']);
20
  $base_url_host = parse_url($gmCore->upload['url'], PHP_URL_HOST);
21
- foreach ($terms as $term) {
 
22
 
23
- foreach ($gmedia[$term->term_id] as $item) {
24
- if ('image' != substr($item->mime_type, 0, 5)) {
25
- continue;
26
- }
27
  $meta = $gmDB->get_metadata('gmedia', $item->ID);
28
- $_metadata = $meta['_metadata'][0];
29
- unset($meta['_metadata']);
30
 
31
  $link_target = '';
32
- if ($item->link) {
33
  $url_host = parse_url($item->link, PHP_URL_HOST);
34
- if ($url_host == $base_url_host || empty($url_host)) {
35
  $link_target = '_self';
36
  } else {
37
  $link_target = '_blank';
38
  }
39
  }
40
- if (isset($meta['link_target'][0])) {
41
  $link_target = $meta['link_target'][0];
42
  }
43
 
44
- $content[] = array(
45
- 'id' => $item->ID,
46
- 'image' => "/{$gmGallery->options['folder']['image']}/{$item->gmuid}",
47
- 'thumb' => "/{$gmGallery->options['folder']['image_thumb']}/{$item->gmuid}",
48
- 'captionTitle' => $item->title,
49
- 'captionText' => str_replace(array("\r\n", "\r", "\n"), '', wpautop($item->description)),
50
- 'media' => '',
51
- 'link' => $item->link,
52
- 'linkTarget' => $link_target,
53
- 'date' => $item->date,
54
- 'websize' => array_values($_metadata['web']),
55
- 'thumbsize' => array_values($_metadata['thumb'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  );
 
 
 
 
 
57
  }
58
  }
59
 
60
- if (! empty($content)) {
61
- $settings = array_merge($settings, array(
62
- 'ID' => $gallery['term_id'],
63
- 'moduleUrl' => $module['url'],
64
- 'pluginUrl' => $gmCore->gmedia_url,
65
- 'libraryUrl' => $gmCore->upload['url']
66
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  $json_settings = json_encode($settings);
68
- $settings = array_merge($module['options'], $settings);
69
  ?>
70
- <?php if (! $is_bot) {
71
- if ($shortcode_raw) { echo '<pre style="display:none">'; }
72
- ?><script type="text/javascript">
73
- jQuery(function () {
 
 
 
74
  var settings = <?php echo $json_settings; ?>;
75
  var content = <?php echo json_encode($content); ?>;
76
  jQuery('#GmediaGallery_<?php echo $gallery['term_id'] ?>').gmPhantom([content, settings]);
77
  });
78
  </script><?php
79
- if ($shortcode_raw) { echo '</pre>'; }
 
 
80
  }
81
  ?>
82
- <div class="gmPhantom_Container delay"<?php if (! $is_bot) { echo ' style="opacity:0.01"'; } ?>>
83
  <div class="gmPhantom_Background"></div>
84
- <div class="gmPhantom_thumbsWrapper">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  <?php $i = 0;
86
- $wrapper_r = $settings['thumbWidth'] / $settings['thumbHeight'];
87
- $tw_size = "width:{$settings['thumbWidth']}px;height:{$settings['thumbHeight']}px;";
88
- foreach ($content as $item) {
89
  $thumb_r = $item['thumbsize'][0] / $item['thumbsize'][1];
90
- if ($wrapper_r < $thumb_r) {
91
  $orientation = 'landscape';
92
- $margin = 'margin:0 0 0 -' . floor(($settings['thumbHeight'] * $thumb_r - $settings['thumbWidth']) / $settings['thumbWidth'] * 50) . '%;';
93
  } else {
94
  $orientation = 'portrait';
95
- $margin = 'margin:-' . floor(($settings['thumbWidth'] / $thumb_r - $settings['thumbHeight']) / $settings['thumbHeight'] * 25) . '% 0 0 0;';
96
  }
97
- ?><div class="gmPhantom_ThumbContainer gmPhantom_ThumbLoader" data-ratio="<?php echo "$wrapper_r/$thumb_r"; ?>" style="<?php echo $tw_size; ?>" data-no="<?php echo $i++; ?>"><?php
98
- ?><div class="gmPhantom_Thumb"><img style="<?php echo $margin; ?>" class="<?php echo $orientation; ?>" src="<?php echo $settings['libraryUrl'] . $item['thumb']; ?>" alt="<?php echo esc_attr($item['captionTitle']); ?>"/></div><?php
99
- if (($settings['thumbsInfo'] == 'label') && ($item['captionTitle'] != '')) {
100
- if (! empty($item['link'])) {
101
- $item['captionTitle'] = "<a href='{$item['link']}' target='{$item['linkTarget']}'>{$item['captionTitle']}</a>";
 
 
 
 
102
  }
103
- ?><div class="gmPhantom_ThumbLabel"><?php echo $item['captionTitle']; ?></div><div style="display:none;" class="gmPhantom_ThumbCaption"><?php echo $item['captionText']; ?></div><?php
 
 
104
  } ?></div><?php
105
  } ?><br style="clear:both;"/>
106
  </div>
9
  * @var $gmedia
10
  * @var $is_bot
11
  **/
12
+
13
+ $settings = array_merge($settings, array(
14
+ 'ID' => $gallery['term_id'],
15
+ 'module_dirurl' => $module['url'],
16
+ 'ajax_actions' => array(
17
+ 'comments' => array(
18
+ 'action' => 'load_comments',
19
+ 'data' => array('post_id' => 0)
20
+ )
21
+ ),
22
+ ));
23
+ $allsettings = array_merge($module['options'], $settings);
24
+
25
  $content = array();
26
+ if(!isset($is_bot)) {
27
  $is_bot = false;
28
  }
29
+ if(!isset($shortcode_raw)) {
30
  $shortcode_raw = false;
31
  }
32
  $tab = sanitize_title($gallery['name']);
33
  $base_url_host = parse_url($gmCore->upload['url'], PHP_URL_HOST);
34
+ $i = 0;
35
+ foreach($terms as $term) {
36
 
37
+ foreach($gmedia[$term->term_id] as $item) {
 
 
 
38
  $meta = $gmDB->get_metadata('gmedia', $item->ID);
39
+ $_metadata = isset($meta['_metadata'])? $meta['_metadata'][0] : array();
 
40
 
41
  $link_target = '';
42
+ if($item->link) {
43
  $url_host = parse_url($item->link, PHP_URL_HOST);
44
+ if($url_host == $base_url_host || empty($url_host)) {
45
  $link_target = '_self';
46
  } else {
47
  $link_target = '_blank';
48
  }
49
  }
50
+ if(isset($meta['link_target'][0])) {
51
  $link_target = $meta['link_target'][0];
52
  }
53
 
54
+ $image = $gmCore->gm_get_media_image($item->ID, 'web');
55
+ $thumb = $gmCore->gm_get_media_image($item->ID, 'thumb');
56
+ $type = explode('/', $item->mime_type);
57
+ $type = $type[0];
58
+ $ext = pathinfo($item->gmuid, PATHINFO_EXTENSION);
59
+ if(!isset($_metadata['web'])) {
60
+ $img_size = getimagesize($image);
61
+ $_metadata['web'] = array_slice($img_size, 0, 2);
62
+ $img_size = getimagesize($thumb);
63
+ $_metadata['thumb'] = array_slice($img_size, 0, 2);
64
+ }
65
+ if($item->post_id) {
66
+ $cc = wp_count_comments($item->post_id);
67
+ $cc = $cc->approved;
68
+ } else {
69
+ $cc = 0;
70
+ }
71
+
72
+ $content[$i] = array(
73
+ 'id' => $item->ID,
74
+ 'post_id' => $item->post_id,
75
+ 'type' => $type,
76
+ 'ext' => strtolower($ext),
77
+ 'src' => "/{$gmGallery->options['folder'][$type]}/{$item->gmuid}",
78
+ 'image' => $image,
79
+ 'thumb' => $thumb,
80
+ 'title' => $item->title,
81
+ 'text' => str_replace(array("\r\n", "\r", "\n"), '', wpautop($item->description)),
82
+ 'cc' => $cc,
83
+ 'views' => empty($meta['views'][0])? 0 : (int)$meta['views'][0],
84
+ 'likes' => empty($meta['likes'][0])? 0 : (int)$meta['likes'][0],
85
+ 'link' => $item->link,
86
+ 'linkTarget' => $link_target,
87
+ 'date' => $item->date,
88
+ 'websize' => array_values($_metadata['web']),
89
+ 'thumbsize' => array_values($_metadata['thumb'])
90
  );
91
+
92
+ if($allsettings['share_post_link']) {
93
+ $content[$i]['post_link'] = get_permalink($item->post_id);
94
+ }
95
+ $i++;
96
  }
97
  }
98
 
99
+ if(!empty($content)) {
100
+ $content = array_values($content);
101
+
102
+ $mfp_id = "#mfp_gm_{$gallery['term_id']}";
103
+ $mfp_css = '';
104
+ if(isset($settings['lightboxControlsColor'])) {
105
+ $mfp_css .= "
106
+ {$mfp_id} .mfp-arrow-right:after,
107
+ {$mfp_id} .mfp-arrow-right .mfp-a {border-left-color:#{$settings['lightboxControlsColor']};}
108
+ {$mfp_id} .mfp-arrow-left:after,
109
+ {$mfp_id} .mfp-arrow-left .mfp-a {border-right-color:#{$settings['lightboxControlsColor']};}
110
+ {$mfp_id} .mfp-close,
111
+ {$mfp_id} .mfp-comments,
112
+ {$mfp_id} .mfp-likes,
113
+ {$mfp_id} .mfp-views,
114
+ {$mfp_id} .mfp-share {color:#{$settings['lightboxControlsColor']};}
115
+ {$mfp_id} .mfp-preloader {background-color:#{$settings['lightboxControlsColor']};}";
116
+ }
117
+ if(isset($settings['lightboxTitleColor'])) {
118
+ $mfp_css .= "
119
+ {$mfp_id} .mfp-title,
120
+ {$mfp_id} .mfp-counter {color:#{$settings['lightboxTitleColor']};}";
121
+ }
122
+ if(isset($settings['lightboxTextColor'])) {
123
+ $mfp_css .= "
124
+ {$mfp_id} .mfp-description {color:#{$settings['lightboxTextColor']};}";
125
+ }
126
+ if(isset($settings['lightboxBGColor'])) {
127
+ $mfp_css .= "
128
+ {$mfp_id}_bg.mfp-bg {background-color:#{$settings['lightboxBGColor']};}";
129
+ }
130
+ if(isset($settings['lightboxBGAlpha'])) {
131
+ $alpha = $settings['lightboxBGAlpha'] / 100;
132
+ $mfp_css .= "
133
+ {$mfp_id}_bg.mfp-bg {opacity:{$alpha};}
134
+ {$mfp_id}_bg.mfp-zoom-in.mfp-bg {opacity:0}
135
+ {$mfp_id}_bg.mfp-zoom-in.mfp-ready.mfp-bg {opacity:{$alpha};}
136
+ {$mfp_id}_bg.mfp-zoom-in.mfp-removing.mfp-bg {opacity:0}";
137
+ }
138
+ if(isset($settings['commentsBGColor']) || isset($settings['commentsBGAlpha'])) {
139
+ if(method_exists($gmCore, 'hex2rgb')) {
140
+ $rgb = implode(',', $gmCore->hex2rgb($allsettings['commentsBGColor']));
141
+ $alpha = $allsettings['commentsBGAlpha'] / 100;
142
+ $mfp_css .= "
143
+ {$mfp_id} .mfp-comments-content {background-color:rgba({$rgb},{$alpha});}";
144
+ } else {
145
+ $mfp_css .= "
146
+ {$mfp_id} .mfp-comments-content {background-color:#{$allsettings['commentsBGColor']};}";
147
+ }
148
+ }
149
+ if($mfp_css) {
150
+ $settings['mfp_css'] = $mfp_css;
151
+ }
152
+
153
+ $cssid = "#GmediaGallery_{$gallery['term_id']}";
154
+ $dcss = '';
155
+ if(isset($settings['thumbWidth']) || isset($settings['thumbHeight']) || isset($settings['thumbWidthMobile']) || isset($settings['thumbHeightMobile'])) {
156
+ $dcss .= "
157
+ {$cssid} .gmPhantom_ThumbContainer {width:{$allsettings['thumbWidth']}px; height:{$allsettings['thumbHeight']}px;}
158
+ {$cssid} .gmPhantom_MobileView .gmPhantom_ThumbContainer {width:{$allsettings['thumbWidthMobile']}px; height:{$allsettings['thumbHeightMobile']}px;}";
159
+ }
160
+ if(isset($settings['thumbPadding'])) {
161
+ $dcss .= "
162
+ {$cssid} .gmPhantom_ThumbContainer {padding:{$allsettings['thumbPadding']}px;}";
163
+ }
164
+ if(isset($settings['thumbBG'])) {
165
+ if('' == $settings['thumbBG']) {
166
+ $dcss .= "
167
+ {$cssid} .gmPhantom_ThumbContainer {background-color:transparent;}";
168
+ } else {
169
+ $dcss .= "
170
+ {$cssid} .gmPhantom_ThumbContainer,
171
+ {$cssid} .gmPhantom_LabelBottom .gmPhantom_ThumbLabel {background-color:#{$settings['thumbBG']};}";
172
+ }
173
+ }
174
+ if(isset($settings['thumbAlpha'])) {
175
+ $alpha = $settings['thumbAlpha'] / 100;
176
+ $dcss .= "
177
+ {$cssid} .gmPhantom_ThumbContainer .gmPhantom_Thumb {opacity:{$alpha};}";
178
+ }
179
+ if(isset($settings['thumbAlphaHover'])) {
180
+ $alpha = $settings['thumbAlphaHover'] / 100;
181
+ $dcss .= "
182
+ {$cssid} .gmPhantom_ThumbContainer:hover .gmPhantom_Thumb {opacity:{$alpha};}";
183
+ }
184
+ if(isset($settings['thumbBorderSize']) || isset($settings['thumbBorderColor'])) {
185
+ if((int)$settings['thumbBorderSize']) {
186
+ $dcss .= "
187
+ {$cssid} .gmPhantom_ThumbContainer {border:{$allsettings['thumbBorderSize']}px solid #{$allsettings['thumbBorderColor']};}";
188
+ } else {
189
+ $dcss .= "
190
+ {$cssid} .gmPhantom_ThumbContainer {border:none;}";
191
+ }
192
+ }
193
+ if(isset($settings['thumbBorderSize'])) {
194
+ if((int)$settings['thumbBorderSize'] > 1) {
195
+ $dcss .= "
196
+ {$cssid} .gmPhantom_ThumbContainer {box-shadow:0 0 5px -2px;}";
197
+ } else {
198
+ $dcss .= "
199
+ {$cssid} .gmPhantom_ThumbContainer {box-shadow:none;}";
200
+ }
201
+ }
202
+ if(isset($settings['label8TextColor'])) {
203
+ $dcss .= "
204
+ {$cssid} .gmPhantom_ThumbLabel {color:#{$allsettings['label8TextColor']};}";
205
+ }
206
+ if(isset($settings['label8LinkColor'])) {
207
+ $dcss .= "
208
+ {$cssid} .gmPhantom_ThumbLabel a {color:#{$allsettings['label8LinkColor']};}";
209
+ }
210
+ if(isset($settings['labelTextColor'])) {
211
+ $dcss .= "
212
+ {$cssid} .gmPhantom_LabelInside .gmPhantom_ThumbLabel,
213
+ {$cssid} .gmPhantom_LabelHover .gmPhantom_ThumbLabel {color:#{$allsettings['labelTextColor']};}";
214
+ }
215
+ if(isset($settings['labelLinkColor'])) {
216
+ $dcss .= "
217
+ {$cssid} .gmPhantom_LabelInside .gmPhantom_ThumbLabel a,
218
+ {$cssid} .gmPhantom_LabelHover .gmPhantom_ThumbLabel a {color:#{$allsettings['labelLinkColor']};}";
219
+ }
220
+ if($dcss) {
221
+ $customCSS = $dcss . $customCSS;
222
+ }
223
+
224
+
225
  $json_settings = json_encode($settings);
226
+
227
  ?>
228
+ <?php if(!$is_bot) {
229
+ if($shortcode_raw) {
230
+ echo '<pre style="display:none">';
231
+ }
232
+ ?>
233
+ <script type="text/javascript">
234
+ jQuery(function() {
235
  var settings = <?php echo $json_settings; ?>;
236
  var content = <?php echo json_encode($content); ?>;
237
  jQuery('#GmediaGallery_<?php echo $gallery['term_id'] ?>').gmPhantom([content, settings]);
238
  });
239
  </script><?php
240
+ if($shortcode_raw) {
241
+ echo '</pre>';
242
+ }
243
  }
244
  ?>
245
+ <div class="gmPhantom_Container noLightbox delay">
246
  <div class="gmPhantom_Background"></div>
247
+ <?php
248
+ $thumbsWrapper_class = (int)$allsettings['thumbScale']? ' gmPhantom_ThumbScale' : '';
249
+ if('label' == $allsettings['thumbsInfo']) {
250
+ if((int)$allsettings['labelOnHover']) {
251
+ $thumbsWrapper_class .= ' gmPhantom_LabelHover';
252
+ } else {
253
+ $thumbsWrapper_class .= ' gmPhantom_LabelInside';
254
+ }
255
+ } elseif('label_bottom' == $allsettings['thumbsInfo']) {
256
+ $thumbsWrapper_class .= ' gmPhantom_LabelBottom';
257
+ } elseif('tooltip' == $allsettings['thumbsInfo']) {
258
+ $thumbsWrapper_class .= ' gmPhantom_LabelTooltip';
259
+ } elseif('none' == $allsettings['thumbsInfo']) {
260
+ $thumbsWrapper_class .= ' gmPhantom_LabelNone';
261
+ }
262
+ ?>
263
+ <div class="gmPhantom_thumbsWrapper<?php echo $thumbsWrapper_class; ?>">
264
  <?php $i = 0;
265
+ $wrapper_r = $allsettings['thumbWidth'] / $allsettings['thumbHeight'];
266
+ $mobile_wrapper_r = $allsettings['thumbWidthMobile'] / $allsettings['thumbHeightMobile'];
267
+ foreach($content as $item) {
268
  $thumb_r = $item['thumbsize'][0] / $item['thumbsize'][1];
269
+ if($wrapper_r < $thumb_r) {
270
  $orientation = 'landscape';
271
+ $margin = 'margin:0 0 0 -' . floor(($allsettings['thumbHeight'] * $thumb_r - $allsettings['thumbWidth']) / $allsettings['thumbWidth'] * 50) . '%;';
272
  } else {
273
  $orientation = 'portrait';
274
+ $margin = 'margin:-' . floor(($allsettings['thumbWidth'] / $thumb_r - $allsettings['thumbHeight']) / $allsettings['thumbHeight'] * 25) . '% 0 0 0;';
275
  }
276
+
277
+ $class = '';
278
+ $style = 'left:50%; top:50%; transform:translate(-50%, -50%);'
279
+ ?>
280
+ <div class="gmPhantom_ThumbContainer gmPhantom_ThumbLoader<?php echo(!in_array($item['type'], array('image'))? " mfp-iframe" : ''); ?>" data-ratio="<?php echo $thumb_r; ?>" data-no="<?php echo $i++; ?>"><?php
281
+ ?><a href="<?php echo $gmCore->upload['url'] . $item['src']; ?>" class="gmPhantom_Thumb"><img style="<?php echo $style; ?>" src="<?php echo $item['thumb']; ?>" alt="<?php echo esc_attr($item['title']); ?>"/></a><?php
282
+ if(in_array($allsettings['thumbsInfo'], array('label', 'label_bottom')) && ($item['title'] != '')) {
283
+ if(!empty($item['link'])) {
284
+ $item['title'] = "<a href='{$item['link']}' target='{$item['linkTarget']}'>{$item['title']}</a>";
285
  }
286
+ ?>
287
+ <div class="gmPhantom_ThumbLabel"><?php echo $item['title']; ?></div>
288
+ <div style="display:none;" class="gmPhantom_ThumbCaption"><?php echo $item['text']; ?></div><?php
289
  } ?></div><?php
290
  } ?><br style="clear:both;"/>
291
  </div>
module/phantom/js/jquery.gmPhantom.js CHANGED
@@ -1,13 +1,14 @@
1
  /*
2
  * Title : gmPhantom
3
- * Version : 2.8
4
  * Copyright : 2013-2015 CodEasily.com
5
  * Website : http://www.codeasily.com
6
  */
7
- if (typeof jQuery.fn.gmPhantom == 'undefined') {
8
- (function ($, window, document) {
9
- $.fn.gmPhantom = function (method) {
10
  var Container = this,
 
11
  ID = '',
12
  Content,
13
  opt,
@@ -17,19 +18,24 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
17
  'thumbsNavigation': 'scroll', // Thumbnails Navigation (mouse, scroll). Default value: mouse. Set how you navigate through the thumbnails.
18
  'thumbsAlign': 'left', // Thumbnails align. Default value: left.
19
  'thumbsInfo': 'label', // Info Thumbnails Display (none, tooltip, label). Default value: tooltip. Display a small info text on the thumbnails, a tooltip or a label on bottom.
20
- 'lightboxPosition': 'document', // Lightbox Position (document, gallery). Default value: document. If the value is document the lightbox is displayed over the web page fitting in the browser's window, else the lightbox is displayed in the gallery's container.
21
- 'moduleUrl': '',
22
- 'libraryUrl': ''
23
  },
24
  opt_hex = {
25
  'bgColor': 'ffffff', // Background Color (color hex code). Default value: ffffff. Set gallery background color.
 
26
  'thumbBorderColor': 'cccccc', // Thumbnail Border Color (color hex code). Default value: cccccc. Set the color of a thumbnail's border.
 
27
  'tooltipBgColor': 'ffffff', // Tooltip Background Color (color hex code). Default value: ffffff. Set tooltip background color.
28
  'tooltipStrokeColor': '000000', // Tooltip Stroke Color (color hex code). Default value: 000000. Set tooltip stroke color.
29
- 'tooltipTextColor': '000000', // Tooltip Text Color (color hex code). Default value: 000000. Set tooltip text color.
30
- 'captionTitleColor': 'ffffff', // Tooltip Text Color (color hex code). Default value: 000000. Set tooltip text color.
31
- 'captionTextColor': 'ffffff', // Tooltip Text Color (color hex code). Default value: 000000. Set tooltip text color.
32
- 'lightboxWindowColor': '000000' // Lightbox Window Color (color hex code). Default value: 000000. Set the color for the lightbox window.
 
 
 
 
33
  },
34
  opt_int = {
35
  'initRPdelay': 100,
@@ -39,6 +45,8 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
39
  'bgAlpha': 0, // Background Alpha (value from 0 to 100). Default value: 0. Set gallery background alpha.
40
  'thumbWidth': 160, // Thumbnail Width (the size in pixels). Default value: 150. Set the width of a thumbnail.
41
  'thumbHeight': 120, // Thumbnail Height (the size in pixels). Default value: 150. Set the height of a thumbnail.
 
 
42
  'thumbsSpacing': 10, // Thumbnails Spacing (value in pixels). Default value: 10. Set the space between thumbnails.
43
  'thumbsVerticalPadding': 5, // Thumbnails Padding Top (value in pixels). Default value: 5. Set the top padding for the thumbnails.
44
  'thumbsHorizontalPadding': 3, // Thumbnails Padding Top (value in pixels). Default value: 5. Set the top padding for the thumbnails.
@@ -46,49 +54,56 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
46
  'thumbAlphaHover': 100, // Thumbnail Alpha Hover (value from 0 to 100). Default value: 100. Set the transparancy of a thumbnail when hover.
47
  'thumbBorderSize': 1, // Thumbnail Border Size (value in pixels). Default value: 1. Set the size of a thumbnail's border.
48
  'thumbPadding': 5, // Thumbnail Padding (value in pixels). Default value: 3. Set padding value of a thumbnail.
49
- 'lightboxWindowAlpha': 80 // Lightbox Window Alpha (value from 0 to 100). Default value: 80. Set the transparancy for the lightbox window.
50
  },
51
  opt_bool = {
52
- 'socialShareEnabled': true // Social Share Enabled (true, false). Default value: true. Enable AddThis Social Share.
 
 
 
 
 
 
 
 
 
53
  },
54
 
55
  IDs = [],
 
 
 
 
56
  Images = [],
57
  Thumbs = [],
58
  CaptionTitle = [],
59
  CaptionText = [],
60
- Media = [],
 
 
 
61
  Links = [],
62
  LinksTarget = [],
63
  noItems = 0,
64
 
 
 
65
  startGalleryID = 0,
66
  startWith = 0,
67
 
68
- currentItem = 0,
 
69
  itemLoaded = false,
70
- ImageWidth = 0,
71
- ImageHeight = 0,
72
- LightboxDisplayTime = 600,
73
- LightboxNavDisplayTime = 200,
74
- LightboxTextDisplayTime = 80,
75
  thumbsNavigationArrowsSpeed = 200,
76
- prevhover = false, nexthover = false,
77
- resize = false,
78
- fix_windowW = 0,
79
- fix_windowH = 0,
80
- scale = 1, translateX = 0, translate_X = 0, translateY = 0, translate_Y = 0,
81
- transform_scale = 'scale(1)',
82
- transform_translate = 'translate(0, 0)',
83
  cc = 0,
84
 
85
  methods = {
86
- init: function (arguments) {// Init Plugin.
87
  opt = $.extend(true, {}, opt_str, opt_int, opt_bool, opt_hex, arguments[1]);
88
- $.each(opt, function (key, val) {
89
- if (key in opt_bool) {
90
  opt[key] = (!(!val || val == '0' || val == 'false'));
91
- } else if (key in opt_int) {
92
  opt[key] = parseInt(val);
93
  }
94
  });
@@ -98,7 +113,8 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
98
  opt.initialRows = opt.thumbRows;
99
  opt.thumbWidthDesktop = opt.thumbWidth;
100
  opt.thumbHeightDesktop = opt.thumbHeight;
101
- opt.ratio = opt.thumbWidth / opt.thumbHeight;
 
102
 
103
  Content = arguments[0];
104
  methods.parseContent();
@@ -107,33 +123,54 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
107
 
108
  setTimeout(methods.initRP, opt.initRPdelay);
109
  },
110
- parseContent: function () {// Parse Content.
111
- $.each(Content, function (index) {
112
- $.each(Content[index], function (key) {
113
- switch (key) {
114
  case 'id':
115
  IDs.push(Content[index][key]);
116
  break;
 
 
 
 
 
 
 
 
 
 
 
 
117
  case 'image':
118
- Images.push(opt.libraryUrl + Content[index][key]);
119
  break;
120
  case 'thumb':
121
- Thumbs.push(opt.libraryUrl + Content[index][key]);
122
  break;
123
- case 'captionTitle':
124
  CaptionTitle.push(Content[index][key]);
125
  break;
126
- case 'captionText':
127
  CaptionText.push(Content[index][key]);
128
  break;
129
- case 'media':
130
- Media.push(Content[index][key]);
 
 
 
 
 
 
 
 
 
131
  break;
132
  case 'link':
133
  Links.push(Content[index][key]);
134
  break;
135
  case 'linkTarget':
136
- if (Content[index][key] === '') {
137
  LinksTarget.push('_self');
138
  }
139
  else {
@@ -150,8 +187,20 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
150
  methods.initGallery();
151
 
152
  },
153
- initGallery: function () {// Init the Gallery
154
- var LightboxHTML = [];
 
 
 
 
 
 
 
 
 
 
 
 
155
  var browser_class = '';
156
  if (prototypes.isIEBrowser()) {
157
  if (prototypes.isIEBrowser() < 8) {
@@ -164,118 +213,554 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
164
  browser_class += ' istouch';
165
  }
166
 
167
- LightboxHTML.push(' <div class="gmPhantom_LightboxWrapper' + browser_class + '" id="gmPhantom_LightboxWrapper_' + ID + '">');
168
- LightboxHTML.push(' <div class="gmPhantom_LightboxBg"></div>');
169
- LightboxHTML.push(' <div class="gmPhantom_LightboxWindow">');
170
- LightboxHTML.push(' <div class="gmPhantom_LightboxNav_PrevBtn gm_lbw_nav"><span>&lsaquo;</span></div>');
171
- LightboxHTML.push(' <div class="gmPhantom_LightboxNav_NextBtn gm_lbw_nav"><span>&rsaquo;</span></div>');
172
- LightboxHTML.push(' <div class="gmPhantom_LightboxContainer">');
173
- LightboxHTML.push(' <div class="gmPhantom_Lightbox"></div>');
174
- LightboxHTML.push(' <div class="gmPhantom_LightboxNav_PrevBtn gm_lbc_nav"></div>');
175
- LightboxHTML.push(' <div class="gmPhantom_LightboxNav_NextBtn gm_lbc_nav"></div>');
176
- LightboxHTML.push(' <div class="gmPhantom_CaptionTitle">');
177
- LightboxHTML.push(' <div class="gmPhantom_title"></div>');
178
- LightboxHTML.push(' </div>');
179
- LightboxHTML.push(' <div class="gmPhantom_CaptionTextContainer">');
180
- LightboxHTML.push(' <div class="gmPhantom_CaptionText"></div>');
181
- LightboxHTML.push(' </div>');
182
- LightboxHTML.push(' </div>');
183
- LightboxHTML.push(' <div class="gmPhantom_counter"><span class="gmPhantom_ItemCount"></span> / ' + noItems + '</div>');
184
- LightboxHTML.push(' <div class="gmPhantom_LightboxNavExtraButtons">');
185
- LightboxHTML.push(' <div class="gmPhantom_LightboxNav_CloseBtn"><span>CLOSE</span></div>');
186
- if (opt.socialShareEnabled) {
187
- LightboxHTML.push(' <div class="gmPhantom_LightboxSocialShare"></div>');
188
  }
189
- LightboxHTML.push(' <div class="gmlog"><p></p></div><br class="gmPhantom_Clear" />');
190
- LightboxHTML.push(' </div>');
191
- if (prototypes.isTouchDevice()) {
192
- LightboxHTML.push(' <div class="gmPhantom_info"><i>i</i></div>');
193
- LightboxHTML.push(' <div class="fix_window" id="fix_window_' + ID + '">&nbsp;</div>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
- LightboxHTML.push(' </div>');
196
- LightboxHTML.push(' </div>');
197
- if (prototypes.isTouchDevice()) {
198
- LightboxHTML.push(' <div class="gmPhantom_bodyBg" id="gmPhantom_bodyBg_' + ID + '" style="background-color: #' + opt.lightboxWindowColor + '"></div>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
- $('.gmPhantom_thumbsWrapper', Container).addClass(browser_class);
202
- if (opt.thumbsInfo == 'tooltip' && !prototypes.isTouchDevice()) {
203
- $('.gmPhantom_Container', Container).append('<div class="gmPhantom_Tooltip"></div>');
 
 
204
  }
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
 
207
- if (opt.lightboxPosition == 'document') {
208
- $('body').append(LightboxHTML.join(''));
 
209
  } else {
210
- Container.append(LightboxHTML.join('')).find('.gmPhantom_LightboxWrapper').css({position: 'absolute'});
211
  }
212
- methods.initSettings();
213
  },
214
- initSettings: function () {// Init Settings
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  methods.initContainer();
216
  methods.initThumbs();
217
- if (opt.thumbsInfo == 'tooltip' && !prototypes.isTouchDevice()) {
218
  methods.initTooltip();
219
  }
220
- methods.initLightbox();
221
- methods.initCaption();
222
 
223
  },
224
- initRP: function () {// Init Resize & Positioning
225
  var rrr = methods.rpResponsive();
226
- if (!rrr && 50 > cc) {
227
  cc++;
228
  clearTimeout(timeout);
229
- timeout = setTimeout(function () {
230
  methods.initRP();
231
  }, 100);
232
  } else {
233
  cc = 0;
234
  methods.rpContainer();
235
  methods.rpThumbs();
236
-
237
- if (itemLoaded) {
238
- if (Media[currentItem - 1] === '') {
239
- resize = true;
240
- methods.rpLightboxImage();
241
- }
242
- else {
243
- methods.rpLightboxMedia();
244
- }
245
- methods.rpCaption();
246
- }
247
  }
248
  },
249
- rpResponsive: function () {
250
  var hiddenBustedItems = prototypes.doHideBuster($(Container));
251
 
252
- if ($(window).width() <= 640) {
253
- opt.thumbWidth = opt.thumbWidthDesktop / 2;
254
- opt.thumbHeight = opt.thumbHeightDesktop / 2;
255
- }
256
- else {
 
 
257
  opt.thumbWidth = opt.thumbWidthDesktop;
258
  opt.thumbHeight = opt.thumbHeightDesktop;
 
259
  }
260
 
261
  opt.width = $(Container).width();
262
-
263
  prototypes.undoHideBuster(hiddenBustedItems);
264
 
265
  return opt.width;
266
  },
267
 
268
- initContainer: function () {// Init Container
269
- setTimeout(function () {
270
- $('.gmPhantom_Container', Container).removeClass('delay').css('opacity', 1);
271
- }, 3000);
272
  $('.gmPhantom_Container', Container).css({'display': 'block', 'text-align': opt.thumbsAlign});
273
 
274
- if (opt.maxheight === 0) {
275
  $('.gmPhantom_Container', Container).css('overflow', 'visible');
276
  }
277
  $('.gmPhantom_Background', Container).css('opacity', opt.bgAlpha / 100);
278
- if (opt.bgAlpha !== 0) {
279
  $('.gmPhantom_Background', Container).css('background-color', '#' + opt.bgColor);
280
  }
281
  $('.gmPhantom_thumbsWrapper', Container).css({
@@ -284,16 +769,16 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
284
  'padding-left': opt.thumbsHorizontalPadding,
285
  'padding-right': opt.thumbsHorizontalPadding
286
  });
287
- if (opt.thumbsAlign == 'left') {
288
  $('.gmPhantom_thumbsWrapper', Container).css({'margin-left': 0});
289
- } else if (opt.thumbsAlign == 'right') {
290
  $('.gmPhantom_thumbsWrapper', Container).css({'margin-right': 0});
291
  }
292
  methods.rpContainer();
293
  },
294
- rpContainer: function () {// Resize & Position Container
295
  $('.gmPhantom_Container', Container).width(opt.width);
296
- if (opt.maxheight === 0) {
297
  $('.gmPhantom_Container', Container).css('height', 'auto');
298
  $('.gmPhantom_thumbsWrapper', Container).css('height', 'auto');
299
  } else {
@@ -301,151 +786,146 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
301
  }
302
  },
303
 
304
- initThumbs: function () {//Init Thumbnails
305
- if (opt.maxheight === 0) {
306
  $('.gmPhantom_thumbsWrapper', Container).css({'overflow': 'visible', 'position': 'relative'});
307
  }
308
 
309
  var thumb_container = $('.gmPhantom_ThumbContainer', Container);
310
- if (!prototypes.isTouchDevice()) {
311
- thumb_container.css('opacity', opt.thumbAlpha / 100)
312
- .hover(function () {
313
- if (opt.thumbsInfo == 'label' && $('.gmPhantom_ThumbLabel', this).length) {
314
- $(this).stop(true, true).animate({'opacity': opt.thumbAlphaHover / 100}, 50);
315
- var top_to = opt.thumbHeight + opt.thumbPadding - $('.gmPhantom_ThumbLabel', this).outerHeight();
316
- $('.gmPhantom_ThumbLabel', this).animate({'top': top_to}, 50);
317
- } else if (opt.thumbsInfo == 'tooltip') {
318
- $(this).stop().animate({'opacity': opt.thumbAlphaHover / 100}, 50);
319
  var no = $(this).data('no');
320
  methods.showTooltip(no);
321
- }
322
- },
323
- function () {
324
- if (opt.thumbsInfo == 'label' && $('.gmPhantom_ThumbLabel', this).length) {
325
- $('.gmPhantom_ThumbLabel', this).stop(true, true).animate({'top': '100%'}, 50);
326
- $(this).animate({'opacity': parseInt(opt.thumbAlpha) / 100}, 50);
327
- } else if (opt.thumbsInfo == 'tooltip') {
328
  $('.gmPhantom_Tooltip', Container).css('display', 'none');
329
- $(this).stop().animate({'opacity': parseInt(opt.thumbAlpha) / 100}, 50);
330
- }
331
- });
332
- }
333
-
334
- if (opt.thumbBorderSize > 0) {
335
- $('.gmPhantom_ThumbContainer', Container).css({
336
- 'border-width': opt.thumbBorderSize,
337
- 'border-color': '#' + opt.thumbBorderColor,
338
- 'border-style': 'solid'
339
- });
340
- if (opt.thumbsSpacing > 1) {
341
- $('.gmPhantom_ThumbContainer', Container).css({'box-shadow': '0 0 5px -2px'});
342
  }
343
  }
344
 
345
- thumb_container.click(function () {
346
  var no = $(this).data('no');
347
- if (Links[no] === '') {
348
- methods.showLightbox(no);
349
- } else {
350
  prototypes.openLink(Links[no], LinksTarget[no]);
351
  }
352
  });
353
- $('.gmPhantom_ThumbLabel a', thumb_container).click(function () {
354
- $(this).closest('.gmPhantom_ThumbContainer').trigger('click');
 
 
355
  return false;
356
  });
 
 
 
357
 
358
- $('.gmPhantom_Thumb img', Container).each(function () {
359
- var img = new Image();
360
- $(img).load(function () {
361
- var img_holder = $(this).closest('.gmPhantom_ThumbContainer');
362
- $(this).animate({'opacity': '1'}, 600, function () {
363
- img_holder.removeClass('gmPhantom_ThumbLoader');
 
 
 
364
  });
365
- }).attr('src', $(this).attr('src')).css('opacity', 0);
366
  });
367
 
368
- if (opt.maxheight !== 0) {
369
- if (prototypes.isTouchDevice()) {
370
  prototypes.touchNavigation($('.gmPhantom_Container', Container), $('.gmPhantom_thumbsWrapper', Container));
371
  }
372
- else if (opt.thumbsNavigation == 'mouse') {
373
  methods.moveThumbs();
374
  }
375
- else if (opt.thumbsNavigation == 'scroll') {
376
  methods.initThumbsScroll();
377
  }
378
  }
379
 
380
  methods.rpThumbs();
381
  },
382
- rpThumbs: function () {// Resize & Position Thumbnails
383
  var thumbW = opt.thumbWidth + opt.thumbBorderSize * 2 + opt.thumbPadding * 2,
384
  no = 0,
385
  hiddenBustedItems = prototypes.doHideBuster($(Container));
386
- if (opt.initialHeight === 0 || (opt.initialCols === 0 && opt.initialRows === 0)) {
387
  opt.thumbCols = parseInt((opt.width + opt.thumbsSpacing - opt.thumbsHorizontalPadding * 2) / (thumbW + opt.thumbsSpacing));
388
  opt.thumbRows = parseInt(noItems / opt.thumbCols);
389
 
390
- if (opt.thumbCols === 0) {
391
  opt.thumbCols = 1;
392
  }
393
 
394
- if (opt.thumbRows * opt.thumbCols < noItems) {
395
  opt.thumbRows++;
396
  }
397
  } else {
398
- if ((opt.thumbRows * opt.thumbCols < noItems) && opt.thumbCols !== 0) {
399
- if (noItems % opt.thumbCols === 0) {
400
  opt.thumbRows = noItems / opt.thumbCols;
401
  } else {
402
  opt.thumbRows = parseInt(noItems / opt.thumbCols) + 1;
403
  }
404
  } else {
405
- if (noItems % opt.thumbRows === 0) {
406
  opt.thumbCols = noItems / opt.thumbRows;
407
  } else {
408
  opt.thumbCols = parseInt(noItems / opt.thumbRows) + 1;
409
  }
410
  }
411
  }
412
- $('.gmPhantom_ThumbContainer', Container).width(opt.thumbWidth).height(opt.thumbHeight).css({'padding': opt.thumbPadding});
413
 
414
- $('.gmPhantom_ThumbContainer', Container).each(function () {
 
 
 
 
 
415
  no++;
416
 
417
- $(this).css('margin', 0);
418
- if (no > opt.thumbCols) {
419
- $(this).css('margin-top', opt.thumbsSpacing);
420
- }
421
- if (no % opt.thumbCols != 1 && opt.thumbCols != 1) {
422
- $(this).css('margin-left', opt.thumbsSpacing);
 
 
423
  }
424
- if (no % opt.thumbCols === 0) {
425
  $(this).css('margin-right', '-1px');
426
  }
427
 
 
 
 
 
 
 
 
 
428
  });
429
  var thumbs_el = $('.gmPhantom_thumbsWrapper', Container),
430
  thumbs_el_width = thumbW * opt.thumbCols + (opt.thumbCols - 1) * opt.thumbsSpacing,
431
  scrollbar_width = 0;
432
  thumbs_el.width(thumbs_el_width);
433
- if (thumbs_el_width >= $('.gmPhantom_Container', Container).width()) {
434
  scrollbar_width = methods.scrollbarWidth();
435
  }
436
 
437
- if (opt.initialHeight !== 0) {
438
  var thumbH = opt.thumbHeight + opt.thumbBorderSize * 2 + opt.thumbPadding * 2,
439
  thumbs_el_height = thumbH * opt.thumbRows + (opt.thumbRows - 1) * opt.thumbsSpacing;
440
- if ((thumbs_el_height + scrollbar_width + opt.thumbsVerticalPadding * 2) >= $('.gmPhantom_Container', Container).height()) {
441
- $('.gmPhantom_thumbsWrapper', Container).height(thumbs_el_height + scrollbar_width);
442
- }
443
- else {
444
- $('.gmPhantom_thumbsWrapper', Container).height($('.gmPhantom_Container', Container).height() - opt.thumbsVerticalPadding * 2);
445
- }
446
 
447
- if ((opt.thumbsNavigation == 'mouse')) {
448
- if ($('.gmPhantom_Container', Container).width() > thumbs_el.outerWidth()) {
449
  thumbs_el.css('margin-left', ($('.gmPhantom_Container', Container).width() - thumbs_el.outerWidth()) / 2);
450
  } else {
451
  thumbs_el.css('margin-left', 0);
@@ -453,7 +933,7 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
453
  thumbs_el.css('margin-top', 0);
454
  }
455
 
456
- if (opt.thumbsNavigation == 'scroll' && typeof(jQuery.fn.jScrollPane) != 'undefined') {
457
  $('.gmPhantom_Container .jspContainer', Container).width($('.gmPhantom_thumbsWrapper', Container).width());
458
  }
459
  }
@@ -462,36 +942,36 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
462
 
463
  prototypes.undoHideBuster(hiddenBustedItems);
464
  },
465
- moveThumbs: function () {// Init thumbnails move
466
  var thumbs_el = $('.gmPhantom_thumbsWrapper', Container);
467
- $('.gmPhantom_Container', Container).mousemove(function (e) {
468
- if (itemLoaded) {
469
  return;
470
  }
471
  var thumbW, thumbH, mousePosition, thumbsPosition;
472
 
473
- if (thumbs_el.outerWidth() > $(this).width()) {
474
  thumbW = opt.thumbWidth + opt.thumbBorderSize * 2 + opt.thumbPadding * 2 + opt.thumbsSpacing - opt.thumbsSpacing / opt.thumbRows + opt.thumbsHorizontalPadding / opt.thumbCols;
475
  mousePosition = e.clientX - $(this).offset().left + parseInt($(this).css('margin-left')) + $(document).scrollLeft();
476
  thumbsPosition = 0 - (mousePosition - thumbW) * (thumbs_el.outerWidth() - $(this).width()) / ($(this).width() - 2 * thumbW);
477
- if (thumbsPosition < (-1) * (thumbs_el.outerWidth() - $(this).width())) {
478
  thumbsPosition = (-1) * (thumbs_el.outerWidth() - $(this).width());
479
  }
480
- if (thumbsPosition > 0) {
481
  thumbsPosition = 0;
482
  }
483
  thumbs_el.css('margin-left', thumbsPosition);
484
  //thumbs_el.animate({'margin-left': thumbsPosition}, { duration: 200, queue: false });
485
  }
486
 
487
- if (thumbs_el.outerHeight() > $(this).height()) {
488
  thumbH = opt.thumbHeight + opt.thumbBorderSize * 2 + opt.thumbPadding * 2 + opt.thumbsSpacing - opt.thumbsSpacing / opt.thumbRows + opt.thumbsVerticalPadding / opt.thumbRows;
489
  mousePosition = e.clientY - $(this).offset().top + parseInt($(this).css('margin-top')) + $(document).scrollTop();
490
  thumbsPosition = 0 - (mousePosition - thumbH) * (thumbs_el.outerHeight() - $(this).height()) / ($(this).height() - 2 * thumbH);
491
- if (thumbsPosition < (-1) * (thumbs_el.outerHeight() - $(this).height())) {
492
  thumbsPosition = (-1) * (thumbs_el.outerHeight() - $(this).height());
493
  }
494
- if (thumbsPosition > 0) {
495
  thumbsPosition = 0;
496
  }
497
  thumbs_el.css('margin-top', thumbsPosition);
@@ -499,722 +979,23 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
499
  }
500
  });
501
  },
502
- initThumbsScroll: function () {//Init Thumbnails Scroll
503
- if (typeof(jQuery.fn.jScrollPane) == 'undefined') {
504
  $('.gmPhantom_Container', Container).css('overflow', 'auto');
505
  } else {
506
- setTimeout(function () {
507
  $('.gmPhantom_Container', Container).jScrollPane({autoReinitialise: true});
508
  }, 10);
509
  }
510
  },
511
- scrollbarWidth: function () {
512
  var div = $('<div style="position:absolute;left:-200px;top:-200px;width:50px;height:50px;overflow:scroll"><div>&nbsp;</div></div>').appendTo('body'),
513
  width = 50 - div.children().innerWidth();
514
  div.remove();
515
  return width;
516
  },
517
- initLightbox: function () {// Init Lightbox
518
- startGalleryID = prototypes.$_GET('gmedia_gallery_id') ? parseInt(prototypes.$_GET('gmedia_gallery_id')) : 0;
519
- startWith = (prototypes.$_GET('gmedia_gallery_share') && (startGalleryID == ID)) ? prototypes.$_GET('gmedia_gallery_share') : 0;
520
- if (startWith) {
521
- startWith = IDs.indexOf(startWith);
522
- }
523
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
524
-
525
- //if(!prototypes.isTouchDevice()){
526
- $('.gmPhantom_LightboxContainer', lightbox).before('<img src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" style="width:1px; height:100%; vertical-align:middle; margin-right: -1px; display: inline;" />');
527
- //}
528
- $('.gmPhantom_LightboxBg', lightbox).css({'background-color': '#' + opt.lightboxWindowColor, 'opacity': opt.lightboxWindowAlpha / 100});
529
-
530
- if (!prototypes.isTouchDevice()) {
531
- $('.gmPhantom_LightboxContainer', lightbox).hover(function () {
532
- $('.gmPhantom_CaptionTitle', this).animate({'height': 'show'}, LightboxTextDisplayTime);
533
- $('.gmPhantom_CaptionTextContainer', this).animate({'height': 'show'}, LightboxTextDisplayTime);
534
- }, function () {
535
- $('.gmPhantom_CaptionTitle', this).animate({'height': 'hide'}, LightboxTextDisplayTime);
536
- $('.gmPhantom_CaptionTextContainer', this).animate({'height': 'hide'}, LightboxTextDisplayTime);
537
- });
538
- $('.gmPhantom_LightboxNav_PrevBtn', lightbox).hover(function () {
539
- prevhover = true;
540
- $('.gmPhantom_LightboxNav_PrevBtn span', lightbox).stop().animate({'left': '0'}, LightboxNavDisplayTime);
541
- }, function () {
542
- prevhover = false;
543
- $('.gmPhantom_LightboxNav_PrevBtn span', lightbox).stop().animate({'left': '-' + $('.gmPhantom_LightboxNav_PrevBtn span', lightbox).outerWidth()}, LightboxNavDisplayTime);
544
- });
545
- $('.gmPhantom_LightboxNav_NextBtn', lightbox).hover(function () {
546
- nexthover = true;
547
- $('.gmPhantom_LightboxNav_NextBtn span', lightbox).stop().animate({'right': '0'}, LightboxNavDisplayTime);
548
- }, function () {
549
- nexthover = false;
550
- $('.gmPhantom_LightboxNav_NextBtn span', lightbox).stop().animate({'right': '-' + $('.gmPhantom_LightboxNav_NextBtn span', lightbox).outerWidth()}, LightboxNavDisplayTime);
551
- });
552
- } else {
553
- $('#gmPhantom_bodyBg_' + ID).height($(document).height());
554
- methods.lightboxNavigationSwipe();
555
- }
556
-
557
- $('.gmPhantom_LightboxNav_PrevBtn', lightbox).click(function () {
558
- methods.previousLightbox();
559
- });
560
-
561
- $('.gmPhantom_LightboxNav_NextBtn', lightbox).click(function () {
562
- methods.nextLightbox();
563
- });
564
-
565
- $('.gmPhantom_LightboxSocialShare', lightbox).on('mouseenter', function () {
566
- setTimeout(function () {
567
- $('#at15s').css('position', 'fixed');
568
- }, 10);
569
- });
570
-
571
- $('.gmPhantom_LightboxNav_CloseBtn span', lightbox).click(function () {
572
- methods.hideLightbox();
573
- });
574
-
575
- $(document).keydown(function (e) {
576
- if (itemLoaded) {
577
- switch (e.keyCode) {
578
- case 27:
579
- methods.hideLightbox();
580
- break;
581
- case 37:
582
- methods.previousLightbox();
583
- break;
584
- case 39:
585
- methods.nextLightbox();
586
- break;
587
- }
588
- }
589
- });
590
-
591
- if (startGalleryID == ID) {
592
- var href = window.location.href,
593
- variables = 'gmedia_wall_grid_gallery_id=' + startGalleryID + '&gmedia_wall_grid_gallery_share=' + startWith;
594
-
595
- if (href.indexOf('?' + variables) == -1) {
596
- variables = '&' + variables;
597
- } else {
598
- variables = '?' + variables;
599
- }
600
-
601
- window.location = '#gmPhantom_ID' + ID;
602
-
603
- try {
604
- window.history.pushState({'html': '', 'pageTitle': document.title}, '', href.split(variables)[0]);
605
- } catch (e) {
606
- console.log(e);
607
- }
608
- }
609
-
610
- if (startWith !== 0) {
611
- methods.showLightbox(startWith);
612
- startWith = 0;
613
- }
614
- },
615
- showLightbox: function (no) {// Show Lightbox
616
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
617
-
618
- if (opt.lightboxPosition == 'document' && !prototypes.isTouchDevice()) {
619
- $(document).on('mousewheel.photobox', function (e) {
620
- e.preventDefault();
621
- e.stopPropagation();
622
- return false;
623
- });
624
- } else {
625
- setTimeout(function () {
626
- var zoomlevel = 100, dpr = 1;
627
- if (typeof(window.devicePixelRatio) !== 'undefined') {
628
- dpr = window.devicePixelRatio;
629
- }
630
- if (window.innerWidth > window.innerHeight) {
631
- zoomlevel *= 0.75;
632
- }
633
- if ($(window).width() == screen.width) {
634
- zoomlevel *= 0.66;
635
- } else {
636
- zoomlevel *= dpr;
637
- }
638
- zoomlevel *= ($('#fix_window_' + ID)[0].offsetLeft + 1) / $(document).width();
639
- $('.gmPhantom_LightboxWindow', '#gmPhantom_LightboxWrapper_' + ID).css('font-size', zoomlevel + '%');
640
- }, 10);
641
- $('.gmPhantom_LightboxBg', lightbox).css('opacity', 1);
642
- $('.gm_lbw_nav', lightbox).css({'overflow': 'visible', 'z-index': 101, 'width': '1px', 'min-width': '1px'});
643
- }
644
-
645
- $('.gmPhantom_LightboxNav_PrevBtn span', lightbox).css({'left': 0});
646
- $('.gmPhantom_LightboxNav_NextBtn span', lightbox).css({'right': 0});
647
- lightbox.fadeIn(LightboxDisplayTime, function () {
648
- if (Media[no] === '') {
649
- methods.loadLightboxImage(no);
650
- } else {
651
- methods.loadLightboxMedia(no);
652
- }
653
- if (prototypes.isTouchDevice()) {
654
- $(this).addClass('gm_show');
655
- } else {
656
- setTimeout(function () {
657
- if (!prevhover) {
658
- $('.gmPhantom_LightboxNav_PrevBtn span', lightbox).animate({'left': '-' + $('.gmPhantom_LightboxNav_PrevBtn span', lightbox).outerWidth()}, LightboxNavDisplayTime);
659
- }
660
- if (!nexthover) {
661
- $('.gmPhantom_LightboxNav_NextBtn span', lightbox).animate({'right': '-' + $('.gmPhantom_LightboxNav_NextBtn span', lightbox).outerWidth()}, LightboxNavDisplayTime);
662
- }
663
- }, 2000);
664
- }
665
- });
666
- },
667
- hideLightbox: function () {// Hide Lightbox
668
- if (itemLoaded) {
669
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
670
- lightbox.removeClass('gm_show').fadeOut(LightboxDisplayTime, function () {
671
- $(document).off('mousewheel.photobox');
672
- currentItem = 0;
673
- itemLoaded = false;
674
- prevhover = nexthover = false;
675
- $('.gmPhantom_LightboxContainer', lightbox).css('opacity', 0);
676
- $('.gmPhantom_Lightbox', lightbox).html('');
677
- });
678
- }
679
- },
680
- loadLightboxImage: function (no) {// Load Lightbox Image
681
- var img = new Image();
682
- img.src = Images[no];
683
-
684
- currentItem = no + 1;
685
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
686
-
687
- $('.gmPhantom_ItemCount', lightbox).html(currentItem);
688
-
689
- $('.gmPhantom_LightboxWindow', lightbox).addClass('gmPhantom_LightboxLoader');
690
-
691
- $(img).one('load', function () {
692
- $('.gmPhantom_LightboxWindow', lightbox).removeClass('gmPhantom_LightboxLoader');
693
- $('.gmPhantom_Lightbox', lightbox).html(this);
694
- $('.gmPhantom_Lightbox img', lightbox).attr('alt', CaptionTitle[no]);
695
- if (opt.socialShareEnabled) {
696
- methods.initSocialShare();
697
- }
698
- lightbox.css('display', 'block');
699
- $('.gmPhantom_LightboxContainer', lightbox).removeAttr('style');
700
- ImageWidth = $(this).width() || this.naturalWidth || 640;
701
- ImageHeight = $(this).height() || this.naturalHeight || 480;
702
-
703
- itemLoaded = true;
704
- scale = 1;
705
- translateX = 0;
706
- translate_X = 0;
707
- translateY = 0;
708
- translate_Y = 0;
709
- transform_scale = 'scale(1)';
710
- transform_translate = 'translate(0, 0)';
711
- methods.showCaption(no);
712
- methods.rpLightboxImage();
713
-
714
- $('.gmPhantom_LightboxContainer', lightbox).stop(true, true).animate({'opacity': 1}, LightboxDisplayTime);
715
- }).each(function () {
716
- if (this.complete) {
717
- $(this).trigger("load");
718
- }
719
- });
720
- },
721
- loadLightboxMedia: function (no) {// Load Lightbox Media
722
- currentItem = no + 1;
723
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
724
-
725
- $('.gmPhantom_ItemCount', lightbox).html(currentItem);
726
-
727
- $('.gmPhantom_LightboxWindow', lightbox).removeClass('gmPhantom_LightboxLoader');
728
- $('.gmPhantom_Lightbox', lightbox).html(Media[no]);
729
- if (opt.socialShareEnabled) {
730
- methods.initSocialShare();
731
- }
732
-
733
- var iframe = $('.gmPhantom_Lightbox', lightbox).children();
734
- var iframeSRC = iframe.attr('src');
735
-
736
- if (iframeSRC !== null) {
737
- if (iframeSRC.indexOf('?') == -1) {
738
- iframe.attr('src', iframeSRC + '?wmode=transparent');
739
- } else {
740
- iframe.attr('src', iframeSRC + '&wmode=transparent');
741
- }
742
- }
743
-
744
- if (iframe.length && iframe.prop("tagName").toUpperCase() == 'IFRAME') {
745
- ImageWidth = parseFloat(iframe.attr('width'));
746
- ImageHeight = parseFloat(iframe.attr('height'));
747
- }
748
- else {
749
- ImageWidth = 0;
750
- ImageHeight = 0;
751
- }
752
-
753
- itemLoaded = true;
754
- scale = 1;
755
- translateX = 0;
756
- translate_X = 0;
757
- translateY = 0;
758
- translate_Y = 0;
759
- transform_scale = 'scale(1)';
760
- transform_translate = 'translate(0, 0)';
761
- methods.showCaption(no);
762
- methods.rpLightboxMedia();
763
-
764
- $('.gmPhantom_LightboxContainer', lightbox).stop(true, true).animate({'opacity': 1}, LightboxDisplayTime);
765
- },
766
- previousLightbox: function () {
767
- var previousItem = currentItem - 2;
768
-
769
- if (currentItem == 1) {
770
- previousItem = noItems;
771
- }
772
-
773
- if (Links[previousItem] === '') {
774
- $('#gmPhantom_LightboxWrapper_' + ID + ' .gmPhantom_LightboxContainer').stop(true, true).animate({'opacity': 0}, LightboxDisplayTime, function () {
775
- if (Media[previousItem] === '') {
776
- methods.loadLightboxImage(previousItem);
777
- } else {
778
- methods.loadLightboxMedia(previousItem);
779
- }
780
- });
781
- }
782
- else {
783
- currentItem = previousItem + 1;
784
- methods.previousLightbox();
785
- }
786
- },
787
- nextLightbox: function () {
788
- var nextItem = currentItem;
789
-
790
- if ((currentItem - 1) == noItems) {
791
- nextItem = 0;
792
- }
793
-
794
- if (Links[nextItem] === '') {
795
- $('#gmPhantom_LightboxWrapper_' + ID + ' .gmPhantom_LightboxContainer').stop(true, true).animate({'opacity': 0}, LightboxDisplayTime, function () {
796
- if (Media[nextItem] === '') {
797
- methods.loadLightboxImage(nextItem);
798
- } else {
799
- methods.loadLightboxMedia(nextItem);
800
- }
801
- });
802
- }
803
- else {
804
- currentItem = nextItem + 1;
805
- methods.nextLightbox();
806
- }
807
- },
808
- rpLightboxImage: function () {// Resize & Position Lightbox Image
809
- var windowW, windowH, maxWidth, maxHeight, currW, currH;
810
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
811
-
812
- if (itemLoaded) {
813
- if (opt.lightboxPosition == 'document') {
814
- if (prototypes.isTouchDevice()) {
815
- windowW = lightbox.width();
816
- windowH = lightbox.height();
817
- maxWidth = windowW;
818
- maxHeight = windowH;
819
- } else {
820
- windowW = $(window).width();
821
- windowH = $(window).height();
822
- maxWidth = windowW - (($(window).width() <= 640) ? 0 : 40);
823
- maxHeight = windowH - (($(window).width() <= 640) ? 0 : 20);
824
- }
825
- } else {
826
- windowW = maxWidth = $('.gmPhantom_Container', Container).width();
827
- windowH = maxHeight = $('.gmPhantom_Container', Container).height();
828
- }
829
-
830
- if (ImageWidth <= maxWidth && ImageHeight <= maxHeight) {
831
- currW = ImageWidth;
832
- currH = ImageHeight;
833
- }
834
- else {
835
- currH = maxHeight;
836
- currW = (ImageWidth * maxHeight) / ImageHeight;
837
-
838
- if (currW > maxWidth) {
839
- currW = maxWidth;
840
- currH = (ImageHeight * maxWidth) / ImageWidth;
841
- }
842
- }
843
-
844
- if (prototypes.isTouchDevice()) {
845
- setTimeout(function () {
846
- var fix_el = $('#fix_window_' + ID)[0];
847
- fix_windowW = fix_el.offsetLeft + 1;
848
- fix_windowH = fix_el.offsetTop + 1;
849
- var fix_top = (windowH - currH) / 2,
850
- fix_left = 'auto';
851
- if ((windowW > fix_windowW) && (currW > fix_windowW)) {
852
- fix_left = (fix_windowW - currW) / 2;
853
- }
854
- if (windowH != fix_windowH) {
855
- fix_top = (fix_windowH - currH) / 2;
856
- }
857
- $('.gmPhantom_LightboxContainer', lightbox).width(currW).height(currH);
858
- if (resize) {
859
- $('.gmPhantom_LightboxContainer', lightbox).animate({'margin-top': fix_top, 'margin-left': fix_left, 'width': currW, 'height': currH}, 200);
860
- resize = false;
861
- } else {
862
- //$('.gmPhantom_LightboxContainer', lightbox).css({'margin-top': fix_top, 'margin-left': fix_left});
863
- }
864
- }, 10);
865
- } else {
866
- $('.gmPhantom_LightboxContainer', lightbox).width(currW).height(currH);
867
- }
868
- }
869
- },
870
- rpLightboxMedia: function () {// Resize & Position Lightbox Media
871
- var windowW, windowH, maxWidth, maxHeight, currW, currH;
872
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
873
-
874
- if (opt.lightboxPosition == 'document') {
875
- if (prototypes.isTouchDevice()) {
876
- windowW = lightbox.width();
877
- windowH = lightbox.height();
878
- maxWidth = windowW;
879
- maxHeight = windowH;
880
- } else {
881
- windowW = $(window).width();
882
- windowH = $(window).height();
883
- maxWidth = windowW - (($(window).width() <= 640) ? 0 : 40);
884
- maxHeight = windowH - (($(window).width() <= 640) ? 0 : 20);
885
- }
886
- } else {
887
- windowW = maxWidth = $('.gmPhantom_Container', Container).width();
888
- windowH = maxHeight = $('.gmPhantom_Container', Container).height();
889
- }
890
-
891
- if (ImageWidth <= maxWidth && ImageHeight <= maxHeight) {
892
- currW = ImageWidth;
893
- currH = ImageHeight;
894
-
895
- if (ImageWidth === 0 && ImageHeight === 0) {
896
- currW = $('.gmPhantom_Lightbox', lightbox).children().width();
897
- currH = $('.gmPhantom_Lightbox', lightbox).children().height();
898
- }
899
- } else {
900
- currH = maxHeight;
901
- currW = (ImageWidth * maxHeight) / ImageHeight;
902
-
903
- if (currW > maxWidth) {
904
- currW = maxWidth;
905
- currH = (ImageHeight * maxWidth) / ImageWidth;
906
- }
907
- }
908
-
909
- $('.gmPhantom_Lightbox', lightbox).width(currW).height(currH).children().width(currW).height(currH);
910
-
911
- $('.gmPhantom_LightboxContainer', lightbox).width(currW).height(currH).css({
912
- 'margin-top': (windowH - $('.gmPhantom_LightboxContainer', lightbox).height()) / 2,
913
- 'margin-left': (windowW - $('.gmPhantom_LightboxContainer', lightbox).width()) / 2
914
- });
915
- },
916
- lightboxNavigationSwipe: function () {
917
- var touchContainer = $('#gmPhantom_LightboxWrapper_' + ID),
918
- imgContainer = $('.gmPhantom_LightboxContainer', touchContainer),
919
- buttons = $('.gmPhantom_LightboxNavExtraButtons', touchContainer),
920
- closeBtn = $('.gmPhantom_LightboxNav_CloseBtn', touchContainer),
921
- shareBtn = $('.gmPhantom_LightboxSocialShare', touchContainer),
922
- touch, startX, startY, currX, currY, start, end, gesture = false,
923
- moveX = 0, moveY = 0, lastTouch = 0,
924
- img_w = ImageWidth,
925
- img_h = ImageHeight;
926
- $('body').bind('orientationchange', function () {
927
- scale = 1;
928
- translateX = 0;
929
- translate_X = 0;
930
- translateY = 0;
931
- translate_Y = 0;
932
- transform_scale = 'scale(1)';
933
- transform_translate = 'translate(0, 0)';
934
- $('.gmPhantom_Lightbox img', touchContainer).css({
935
- 'transform': transform_scale + ' ' + transform_translate,
936
- '-webkit-transform': transform_scale + ' ' + transform_translate
937
- });
938
-
939
- var zoomlevel = 100, dpr = 1;
940
- if (typeof(window.devicePixelRatio) !== 'undefined') {
941
- dpr = window.devicePixelRatio;
942
- }
943
- if (window.innerWidth > window.innerHeight) {
944
- zoomlevel *= 0.75;
945
- }
946
- if ($(window).width() != screen.width) {
947
- zoomlevel *= dpr;
948
- } else {
949
- zoomlevel *= 0.66;
950
- }
951
- zoomlevel *= ($('#fix_window_' + ID)[0].offsetLeft + 1) / $(document).width();
952
- $('.gmPhantom_LightboxWindow', touchContainer).css('font-size', zoomlevel + '%');
953
- });
954
- touchContainer.bind('touchstart touchmove touchend', function (e) {
955
- if (e.originalEvent.touches.length > 1) {
956
- gesture = true;
957
- return;
958
- }
959
- touch = e.originalEvent.touches[0];
960
- var now;
961
- if (e.type == 'touchstart') {
962
- now = e.timeStamp;
963
- var delta = now - lastTouch;
964
- if (delta > 20 && delta < 400) {
965
- lastTouch = 0;
966
- e.preventDefault();
967
- e.stopPropagation();
968
- return;
969
- } else {
970
- lastTouch = now;
971
- }
972
- moveX = moveY = 0;
973
- startX = currX = touch.clientX;
974
- startY = currY = touch.clientY;
975
- start = now;
976
- translate_X = translateX;
977
- translate_Y = translateY;
978
- } else if (e.type == 'touchmove') {
979
- e.preventDefault();
980
- currX = touch.clientX;
981
- currY = touch.clientY;
982
- moveX = currX - startX;
983
- moveY = currY - startY;
984
- if (scale == 1) {
985
- translateX = 0;
986
- translateY = 0;
987
- $('img', imgContainer).css({'margin-top': moveY, 'margin-left': moveX});
988
- if (moveX > 0) {
989
- $('.gmPhantom_LightboxNav_PrevBtn', imgContainer).css({'width': moveX});
990
- } else if (moveX < 0) {
991
- $('.gmPhantom_LightboxNav_NextBtn', imgContainer).css({'width': Math.abs(moveX)});
992
- } else {
993
- $('.gm_lbc_nav', imgContainer).css({'width': 0});
994
- }
995
-
996
- if (moveY < 0) {
997
- if (moveY > -fix_windowH / 4) {
998
- shareBtn.removeClass('hover');
999
- } else {
1000
- shareBtn.addClass('hover');
1001
- }
1002
- } else {
1003
- if (moveY < fix_windowH / 4) {
1004
- closeBtn.removeClass('hover');
1005
- } else {
1006
- closeBtn.addClass('hover');
1007
- }
1008
- }
1009
- } else {
1010
- if (fix_windowW < img_w) {
1011
- translate_X = translateX + moveX / scale;
1012
- var min_translate_x = (img_w - fix_windowW) / 2 / scale;
1013
- if (min_translate_x < Math.abs(translate_X)) {
1014
- translate_X = min_translate_x * (translate_X < 0 ? -1 : 1);
1015
- }
1016
- } else {
1017
- translate_X = 0;
1018
- }
1019
- if (fix_windowH < img_h) {
1020
- translate_Y = translateY + moveY / scale;
1021
- var min_translate_y = (img_h - fix_windowH) / 2 / scale;
1022
- if (min_translate_y < Math.abs(translate_Y)) {
1023
- translate_Y = min_translate_y * (translate_Y < 0 ? -1 : 1);
1024
- }
1025
- } else {
1026
- translate_Y = 0;
1027
- }
1028
- }
1029
- transform_translate = 'translate(' + translate_X + 'px, ' + translate_Y + 'px)';
1030
- $('img', imgContainer).css({
1031
- 'transform': transform_scale + ' ' + transform_translate,
1032
- '-webkit-transform': transform_scale + ' ' + transform_translate
1033
- });
1034
- } else if (e.type == 'touchend') {
1035
- now = e.timeStamp;
1036
- if (e.originalEvent.touches.length > 0) {
1037
- moveX = moveY = 0;
1038
- startX = currX = touch.clientX;
1039
- startY = currY = touch.clientY;
1040
- start = now;
1041
- } else {
1042
- translateX = translate_X;
1043
- translateY = translate_Y;
1044
- end = now;
1045
- closeBtn.removeClass('hover');
1046
- shareBtn.removeClass('hover');
1047
- if (scale == 1) {
1048
- if (gesture) {
1049
- gesture = false;
1050
- return;
1051
- }
1052
- if ((moveX === 0) && (moveY === 0)) {
1053
- if ($(e.target).closest('div.gmPhantom_LightboxContainer').length) {
1054
- $('.gmPhantom_CaptionTitle', touchContainer).animate({'height': 'toggle'}, LightboxTextDisplayTime);
1055
- $('.gmPhantom_CaptionTextContainer', touchContainer).animate({'height': 'toggle'}, LightboxTextDisplayTime);
1056
- }
1057
- } else {
1058
- if (moveY < -fix_windowH / 4) {
1059
- moveY = 0;
1060
- $('a', shareBtn).click();
1061
- } else if (moveY > fix_windowH / 4) {
1062
- moveY = 0;
1063
- methods.hideLightbox();
1064
- } else {
1065
- if (moveX > fix_windowW / 5) {
1066
- moveX = 0;
1067
- methods.previousLightbox();
1068
- } else if (moveX < -fix_windowW / 5) {
1069
- moveX = 0;
1070
- methods.nextLightbox();
1071
- }
1072
- }
1073
- }
1074
- }
1075
- $('img', imgContainer).animate({'margin-top': 0, 'margin-left': 0}, 200);
1076
- $('.gm_lbc_nav', imgContainer).animate({'width': 0}, 200);
1077
- }
1078
- }
1079
- });
1080
- touchContainer.bind('gesturechange gestureend', function (e) {
1081
- e.preventDefault();
1082
- var orig = e.originalEvent,
1083
- zoom_0 = (Math.round(orig.scale * 100) / 100 - 1) * scale;
1084
-
1085
- var zoom = scale + zoom_0;
1086
- if (zoom <= 1) {
1087
- zoom = 1;
1088
- translate_X = 0;
1089
- translate_Y = 0;
1090
- buttons.show();
1091
- } else {
1092
- buttons.hide();
1093
- img_w = Math.round(ImageWidth * zoom);
1094
- img_h = Math.round(ImageHeight * zoom);
1095
- if (fix_windowW < img_w) {
1096
- var min_translate_x = (img_w - fix_windowW) / 2 / zoom;
1097
- if (min_translate_x < Math.abs(translate_X)) {
1098
- translate_X = min_translate_x * (translate_X < 0 ? -1 : 1);
1099
- }
1100
- } else {
1101
- translate_X = 0;
1102
- }
1103
- if (fix_windowH < img_h) {
1104
- var min_translate_y = (img_h - fix_windowH) / 2 / zoom;
1105
- if (min_translate_y < Math.abs(translate_Y)) {
1106
- translate_Y = min_translate_y * (translate_Y < 0 ? -1 : 1);
1107
- }
1108
- } else {
1109
- translate_Y = 0;
1110
- }
1111
- }
1112
- transform_scale = 'scale(' + zoom + ')';
1113
- transform_translate = 'translate(' + translate_X + 'px, ' + translate_Y + 'px)';
1114
- if (e.type == 'gesturechange') {
1115
- $('img', imgContainer).css({
1116
- 'transform': transform_scale + ' ' + transform_translate,
1117
- '-webkit-transform': transform_scale + ' ' + transform_translate
1118
- });
1119
- } else if (e.type == 'gestureend') {
1120
- scale = zoom;
1121
- }
1122
- });
1123
- },
1124
-
1125
- initCaption: function () {// Init Caption
1126
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
1127
- $('.gmPhantom_CaptionTitle', lightbox).css('color', '#' + opt.captionTitleColor);
1128
- $('.gmPhantom_CaptionText', lightbox).css('color', '#' + opt.captionTextColor);
1129
- if (typeof(jQuery.fn.jScrollPane) != 'undefined') {
1130
- $('.gmPhantom_CaptionTextContainer', lightbox).jScrollPane();
1131
- }
1132
- },
1133
- showCaption: function (no) {// Show Caption
1134
- var lightbox = $('#gmPhantom_LightboxWrapper_' + ID);
1135
- if (CaptionTitle[no] === '') {
1136
- $('.gmPhantom_CaptionTitle', lightbox).css('visibility', 'hidden');
1137
- }
1138
- else {
1139
- $('.gmPhantom_CaptionTitle', lightbox).css('visibility', 'visible');
1140
- $('.gmPhantom_CaptionTitle .gmPhantom_title', lightbox).html(CaptionTitle[no]);
1141
- }
1142
- if (CaptionText[no] === '') {
1143
- $('.gmPhantom_CaptionTextContainer', lightbox).css('visibility', 'hidden');
1144
- }
1145
- else {
1146
- $('.gmPhantom_CaptionTextContainer', lightbox).css('visibility', 'visible');
1147
- $('.gmPhantom_CaptionText', lightbox).html($("<div />").html(CaptionText[no]));
1148
- }
1149
- if (prototypes.isTouchDevice()) {
1150
- if ((CaptionTitle[no] !== '' || CaptionText[no] !== '')) {
1151
- $('.gmPhantom_info').show();
1152
- } else {
1153
- $('.gmPhantom_info').hide();
1154
- }
1155
- }
1156
- },
1157
- rpCaption: function () {// Resize & Position Caption
1158
- if (typeof(jQuery.fn.jScrollPane) != 'undefined') {
1159
- setTimeout(function () {
1160
- $('#gmPhantom_LightboxWrapper_' + ID + ' .gmPhantom_CaptionTextContainer').jScrollPane();
1161
- }, 100);
1162
- }
1163
- },
1164
-
1165
- initSocialShare: function () {
1166
- var HTML = [],
1167
- itemID = IDs[currentItem - 1],
1168
- URL = window.location.href + (window.location.href.indexOf('?') == -1 ? '?' : '&') + 'gmedia_gallery_id=' + ID + '&gmedia_gallery_share=' + itemID;
1169
-
1170
- HTML.push(' <div class="gmAddThisShareButton" id="addthis_' + ID + '-' + itemID + '">');
1171
- HTML.push(' <a class="addthis_button_expanded" href="#" addthis:url="' + URL + '" addthis:title="' + CaptionTitle[currentItem - 1] + '">');
1172
- HTML.push(' <span>SHARE</span>');
1173
- HTML.push(' </a>');
1174
- HTML.push(' </div>');
1175
-
1176
- var ui_offset_left = -10000,
1177
- ui_offset_top = -12;
1178
- if (opt.lightboxPosition == 'document') {
1179
- ui_offset_left = 5;
1180
- }
1181
- var addthis_wrapper = $('#gmPhantom_LightboxWrapper_' + ID + ' .gmPhantom_LightboxSocialShare'),
1182
- addthis_cur;
1183
- window.addthis_config = {
1184
- ui_click: false,
1185
- ui_offset_left: ui_offset_left,
1186
- ui_offset_top: ui_offset_top,
1187
- services_exclude: 'print',
1188
- ui_cobrand: 'Gmedia Gallery'
1189
- };
1190
- window.addthis_share = {
1191
- url: URL,
1192
- title: CaptionTitle[currentItem - 1],
1193
- templates: {
1194
- twitter: '{{title}} {{url}}'
1195
- }
1196
- };
1197
- if ((typeof(window.addthis) === 'undefined') || (typeof(window.addthis.toolbox) === 'undefined')) {
1198
-
1199
- $.getScript('http://s7.addthis.com/js/300/addthis_widget.js')
1200
- .done(function () {
1201
- if (window.addthis) {
1202
- addthis_wrapper.html(HTML.join(''));
1203
- }
1204
- })
1205
- .fail(function () {
1206
- addthis_wrapper.empty();
1207
- });
1208
-
1209
- } else {
1210
- addthis_wrapper.html(HTML.join(''));
1211
- addthis_cur = document.getElementById('addthis_' + ID + '-' + itemID);
1212
- window.addthis.toolbox(addthis_cur);
1213
- }
1214
- },
1215
-
1216
- initTooltip: function () {// Init Tooltip
1217
- $('.gmPhantom_ThumbContainer', Container).on('mouseover mousemove', function (e) {
1218
  var thumbs_wrapper = $('.gmPhantom_thumbsWrapper', Container),
1219
  mousePositionX = e.clientX - $(thumbs_wrapper).offset().left + parseInt($(thumbs_wrapper).css('margin-left')) + $(document).scrollLeft(),
1220
  mousePositionY = e.clientY - $(thumbs_wrapper).offset().top + parseInt($(thumbs_wrapper).css('margin-top')) + $(document).scrollTop();
@@ -1223,25 +1004,24 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
1223
  $('.gmPhantom_Tooltip', Container).css('top', mousePositionY - $('.gmPhantom_Tooltip', Container).height() - 15);
1224
  });
1225
  },
1226
- showTooltip: function (no) {// Resize, Position & Display the Tooltip
1227
  var HTML = [];
1228
  HTML.push(CaptionTitle[no]);
1229
  HTML.push('<div class="gmPhantom_Tooltip_ArrowBorder"></div>');
1230
  HTML.push('<div class="gmPhantom_Tooltip_Arrow"></div>');
1231
  $('.gmPhantom_Tooltip', Container).html(HTML.join(""));
1232
-
1233
- if (opt.tooltipBgColor != 'css') {
1234
  $('.gmPhantom_Tooltip', Container).css('background-color', '#' + opt.tooltipBgColor);
1235
  $('.gmPhantom_Tooltip_Arrow', Container).css('border-top-color', '#' + opt.tooltipBgColor);
1236
  }
1237
- if (opt.tooltipStrokeColor != 'css') {
1238
  $('.gmPhantom_Tooltip', Container).css('border-color', '#' + opt.tooltipStrokeColor);
1239
  $('.gmPhantom_Tooltip_ArrowBorder', Container).css('border-top-color', '#' + opt.tooltipStrokeColor);
1240
  }
1241
- if (opt.tooltipTextColor != 'css') {
1242
  $('.gmPhantom_Tooltip', Container).css('color', '#' + opt.tooltipTextColor);
1243
  }
1244
- if (CaptionTitle[no] !== '') {
1245
  $('.gmPhantom_Tooltip', Container).css('display', 'block');
1246
  }
1247
  }
@@ -1252,42 +1032,42 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
1252
  var myNav = navigator.userAgent.toLowerCase();
1253
  return (myNav.indexOf('msie') == -1) ? false : parseInt(myNav.split('msie')[1]);
1254
  },
1255
- isTouchDevice: function () {// Detect Touchscreen devices
1256
  return 'ontouchend' in document;
1257
  },
1258
- touchNavigation: function (parent, child) {// One finger Navigation for touchscreen devices
1259
  var prevX, prevY, currX, currY, touch, moveTo, thumbsPositionX, thumbsPositionY,
1260
  thumbW = opt.thumbWidth + 2 * opt.thumbPadding + 2 * opt.thumbBorderSize,
1261
  thumbH = opt.thumbHeight + 2 * opt.thumbPadding + 2 * opt.thumbBorderSize;
1262
 
1263
 
1264
- parent.bind('touchstart', function (e) {
1265
  touch = e.originalEvent.touches[0];
1266
  prevX = touch.clientX;
1267
  prevY = touch.clientY;
1268
  });
1269
 
1270
- parent.bind('touchmove', function (e) {
1271
  touch = e.originalEvent.touches[0];
1272
  currX = touch.clientX;
1273
  currY = touch.clientY;
1274
- thumbsPositionX = currX > prevX ? parseInt(child.css('margin-left')) + (currX - prevX) : parseInt(child.css('margin-left')) - (prevX - currX);
1275
- thumbsPositionY = currY > prevY ? parseInt(child.css('margin-top')) + (currY - prevY) : parseInt(child.css('margin-top')) - (prevY - currY);
1276
 
1277
- if (thumbsPositionX < (-1) * (child.width() - parent.width())) {
1278
- thumbsPositionX = (-1) * (child.width() - parent.width());
1279
  }
1280
- else if (thumbsPositionX > 0) {
1281
  thumbsPositionX = 0;
1282
  }
1283
  else {
1284
  e.preventDefault();
1285
  }
1286
 
1287
- if (thumbsPositionY < (-1) * (child.height() - parent.height())) {
1288
- thumbsPositionY = (-1) * (child.height() - parent.height());
1289
  }
1290
- else if (thumbsPositionY > 0) {
1291
  thumbsPositionY = 0;
1292
  }
1293
  else {
@@ -1297,53 +1077,18 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
1297
  prevX = currX;
1298
  prevY = currY;
1299
 
1300
- if (parent.width() < child.width()) {
1301
  child.css('margin-left', thumbsPositionX);
1302
  }
1303
- if (parent.height() < child.height()) {
1304
  child.css('margin-top', thumbsPositionY);
1305
  }
1306
  });
1307
 
1308
- parent.bind('touchend', function (e) {
1309
- e.preventDefault();
1310
- var arrowsClicked;
1311
- if (thumbsPositionX % (opt.thumbWidth + opt.thumbsSpacing) !== 0) {
1312
- if ($('.gMedia_thumbScroller_thumbs', Container).width() > $('.gMedia_thumbScroller_thumbsWrapper', Container).width()) {
1313
- if (prevX > touch.clientX) {
1314
- moveTo = parseInt(thumbsPositionX / (thumbW + opt.thumbsSpacing)) * (thumbW + opt.thumbsSpacing);
1315
- }
1316
- else {
1317
- moveTo = (parseInt(thumbsPositionX / (thumbW + opt.thumbsSpacing)) - 1) * (thumbW + opt.thumbsSpacing);
1318
- }
1319
- arrowsClicked = true;
1320
-
1321
- $('.gMedia_thumbScroller_thumbs', Container).stop(true, true).animate({'margin-left': moveTo}, thumbsNavigationArrowsSpeed, function () {
1322
- arrowsClicked = false;
1323
- });
1324
- }
1325
- }
1326
-
1327
- if (thumbsPositionY % (opt.thumbHeight + opt.thumbsSpacing) !== 0) {
1328
- if ($('.gMedia_thumbScroller_thumbs', Container).height() > $('.gMedia_thumbScroller_thumbsWrapper', Container).height()) {
1329
- if (prevY > touch.clientY) {
1330
- moveTo = parseInt(thumbsPositionY / (thumbH + opt.thumbsSpacing)) * (thumbH + opt.thumbsSpacing);
1331
- }
1332
- else {
1333
- moveTo = (parseInt(thumbsPositionY / (thumbH + opt.thumbsSpacing)) - 1) * (thumbH + opt.thumbsSpacing);
1334
- }
1335
- arrowsClicked = true;
1336
-
1337
- $('.gMedia_thumbScroller_thumbs', Container).stop(true, true).animate({'margin-top': moveTo}, thumbsNavigationArrowsSpeed, function () {
1338
- arrowsClicked = false;
1339
- });
1340
- }
1341
- }
1342
- });
1343
  },
1344
 
1345
- openLink: function (url, target) {// Open a link.
1346
- switch (target.toLowerCase()) {
1347
  case '_blank':
1348
  window.open(url);
1349
  break;
@@ -1357,15 +1102,15 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
1357
  window.location = url;
1358
  }
1359
  },
1360
- $_GET: function (variable) {
1361
  var url = window.location.href.split('?')[1];
1362
- if (url) {
1363
  url = url.split('#')[0];
1364
- var variables = (typeof(url) === 'undefined') ? [] : url.split('&'),
1365
  i;
1366
 
1367
- for (i = 0; i < variables.length; i++) {
1368
- if (variables[i].indexOf(variable) != -1) {
1369
  return variables[i].split('=')[1];
1370
  }
1371
  }
@@ -1373,27 +1118,23 @@ if (typeof jQuery.fn.gmPhantom == 'undefined') {
1373
 
1374
  return false;
1375
  },
1376
- doHideBuster: function (item) {// Make all parents & current item visible
1377
  var parent = item.parent(),
1378
  items = [];
1379
 
1380
  if (typeof(item.prop('tagName')) !== 'undefined' && item.prop('tagName').toLowerCase() != 'body') {
1381
- items = prototypes.doHideBuster(parent);
1382
- }
1383
 
1384
- if (item.css('display') == 'none') {
1385
- //item.css('display', 'block');
1386
  item.addClass('gmShowBuster');
1387
  items.push(item);
1388
  }
1389
 
1390
  return items;
1391
  }
1
  /*
2
  * Title : gmPhantom
3
+ * Version : 3.3
4
  * Copyright : 2013-2015 CodEasily.com
5
  * Website : http://www.codeasily.com
6
  */
7
+ if(typeof jQuery.fn.gmPhantom == 'undefined') {
8
+ (function($, window, document) {
9
+ $.fn.gmPhantom = function(method) {
10
  var Container = this,
11
+ elID = $(this).attr('id'),
12
  ID = '',
13
  Content,
14
  opt,
18
  'thumbsNavigation': 'scroll', // Thumbnails Navigation (mouse, scroll). Default value: mouse. Set how you navigate through the thumbnails.
19
  'thumbsAlign': 'left', // Thumbnails align. Default value: left.
20
  'thumbsInfo': 'label', // Info Thumbnails Display (none, tooltip, label). Default value: tooltip. Display a small info text on the thumbnails, a tooltip or a label on bottom.
21
+ 'mfp_css': '',
22
+ 'module_dirurl': '',
 
23
  },
24
  opt_hex = {
25
  'bgColor': 'ffffff', // Background Color (color hex code). Default value: ffffff. Set gallery background color.
26
+ 'thumbBG': 'ffffff', // Thumbnail Border Color (color hex code). Default value: cccccc. Set the color of a thumbnail's border.
27
  'thumbBorderColor': 'cccccc', // Thumbnail Border Color (color hex code). Default value: cccccc. Set the color of a thumbnail's border.
28
+ 'tooltipTextColor': '0b0b0b', // Tooltip Text Color (color hex code). Default value: 000000. Set tooltip text color.
29
  'tooltipBgColor': 'ffffff', // Tooltip Background Color (color hex code). Default value: ffffff. Set tooltip background color.
30
  'tooltipStrokeColor': '000000', // Tooltip Stroke Color (color hex code). Default value: 000000. Set tooltip stroke color.
31
+ 'labelTextColor': 'e7e7e7', // Label-Over Text Color (color hex code). Default value: 000000.
32
+ 'labelLinkColor': 'e7e179',
33
+ 'label8TextColor': '0b0b0b', // Label Text Color (color hex code). Default value: 000000.
34
+ 'label8LinkColor': '3695E7',
35
+ 'lightboxControlsColor': 'ffffff', // Tooltip Text Color (color hex code). Default value: 000000.
36
+ 'lightboxTitleColor': 'f3f3f3', // Tooltip Text Color (color hex code). Default value: 000000.
37
+ 'lightboxTextColor': 'f3f3f3', // Tooltip Text Color (color hex code). Default value: 000000.
38
+ 'lightboxBGColor': '0b0b0b' // Lightbox Window Color (color hex code). Default value: 000000. Set the color for the lightbox window.
39
  },
40
  opt_int = {
41
  'initRPdelay': 100,
45
  'bgAlpha': 0, // Background Alpha (value from 0 to 100). Default value: 0. Set gallery background alpha.
46
  'thumbWidth': 160, // Thumbnail Width (the size in pixels). Default value: 150. Set the width of a thumbnail.
47
  'thumbHeight': 120, // Thumbnail Height (the size in pixels). Default value: 150. Set the height of a thumbnail.
48
+ 'thumbWidthMobile': 96,
49
+ 'thumbHeightMobile': 72,
50
  'thumbsSpacing': 10, // Thumbnails Spacing (value in pixels). Default value: 10. Set the space between thumbnails.
51
  'thumbsVerticalPadding': 5, // Thumbnails Padding Top (value in pixels). Default value: 5. Set the top padding for the thumbnails.
52
  'thumbsHorizontalPadding': 3, // Thumbnails Padding Top (value in pixels). Default value: 5. Set the top padding for the thumbnails.
54
  'thumbAlphaHover': 100, // Thumbnail Alpha Hover (value from 0 to 100). Default value: 100. Set the transparancy of a thumbnail when hover.
55
  'thumbBorderSize': 1, // Thumbnail Border Size (value in pixels). Default value: 1. Set the size of a thumbnail's border.
56
  'thumbPadding': 5, // Thumbnail Padding (value in pixels). Default value: 3. Set padding value of a thumbnail.
57
+ 'lightboxBGAlpha': 80 // Lightbox Window Alpha (value from 0 to 100). Default value: 80. Set the transparancy for the lightbox window.
58
  },
59
  opt_bool = {
60
+ 'deepLinks': true,
61
+ 'socialShareEnabled': true, // Social Share Enabled (true, false). Default value: true.
62
+ 'share_post_link': false,
63
+ 'viewsEnabled': true,
64
+ 'likesEnabled': true,
65
+ 'commentsEnabled': true, // Comments Enabled (true, false). Default value: true.
66
+ 'lightbox800HideArrows': false, // Hide Arrows if window width less than 800px.
67
+ 'thumbScale': true, // Scale effect for thumb on mouseover
68
+ 'labelOnHover': true, // Show thumb label only on mouseover
69
+ 'thumb2link': true // Open link instead of lightbox when item have "link" attr
70
  },
71
 
72
  IDs = [],
73
+ Post_IDs = [],
74
+ Types = [],
75
+ Extentions = [],
76
+ Sources = [],
77
  Images = [],
78
  Thumbs = [],
79
  CaptionTitle = [],
80
  CaptionText = [],
81
+ CommentsCount = [],
82
+ ViewsCount = [],
83
+ LikesCount = [],
84
+ PostLinks = [],
85
  Links = [],
86
  LinksTarget = [],
87
  noItems = 0,
88
 
89
+ Storage = {},
90
+
91
  startGalleryID = 0,
92
  startWith = 0,
93
 
94
+ scrollTop = 0,
95
+ scrollLeft = 0,
96
  itemLoaded = false,
 
 
 
 
 
97
  thumbsNavigationArrowsSpeed = 200,
 
 
 
 
 
 
 
98
  cc = 0,
99
 
100
  methods = {
101
+ init: function(arguments) {// Init Plugin.
102
  opt = $.extend(true, {}, opt_str, opt_int, opt_bool, opt_hex, arguments[1]);
103
+ $.each(opt, function(key, val) {
104
+ if(key in opt_bool) {
105
  opt[key] = (!(!val || val == '0' || val == 'false'));
106
+ } else if(key in opt_int) {
107
  opt[key] = parseInt(val);
108
  }
109
  });
113
  opt.initialRows = opt.thumbRows;
114
  opt.thumbWidthDesktop = opt.thumbWidth;
115
  opt.thumbHeightDesktop = opt.thumbHeight;
116
+ opt.dratio = opt.thumbWidthDesktop / opt.thumbHeightDesktop;
117
+ opt.mratio = opt.thumbWidthMobile / opt.thumbHeightMobile;
118
 
119
  Content = arguments[0];
120
  methods.parseContent();
123
 
124
  setTimeout(methods.initRP, opt.initRPdelay);
125
  },
126
+ parseContent: function() {// Parse Content.
127
+ $.each(Content, function(index) {
128
+ $.each(Content[index], function(key) {
129
+ switch(key) {
130
  case 'id':
131
  IDs.push(Content[index][key]);
132
  break;
133
+ case 'post_id':
134
+ Post_IDs.push(Content[index][key]);
135
+ break;
136
+ case 'type':
137
+ Types.push(Content[index][key]);
138
+ break;
139
+ case 'ext':
140
+ Extentions.push(Content[index][key]);
141
+ break;
142
+ case 'src':
143
+ Sources.push(GmediaGallery.upload_dirurl + Content[index][key]);
144
+ break;
145
  case 'image':
146
+ Images.push(Content[index][key]);
147
  break;
148
  case 'thumb':
149
+ Thumbs.push(Content[index][key]);
150
  break;
151
+ case 'title':
152
  CaptionTitle.push(Content[index][key]);
153
  break;
154
+ case 'text':
155
  CaptionText.push(Content[index][key]);
156
  break;
157
+ case 'cc':
158
+ CommentsCount.push(Content[index][key]);
159
+ break;
160
+ case 'views':
161
+ ViewsCount.push(Content[index][key]);
162
+ break;
163
+ case 'likes':
164
+ LikesCount.push(Content[index][key]);
165
+ break;
166
+ case 'post_link':
167
+ PostLinks.push(Content[index][key]);
168
  break;
169
  case 'link':
170
  Links.push(Content[index][key]);
171
  break;
172
  case 'linkTarget':
173
+ if(Content[index][key] === '') {
174
  LinksTarget.push('_self');
175
  }
176
  else {
187
  methods.initGallery();
188
 
189
  },
190
+ initGallery: function() {// Init the Gallery
191
+
192
+ var currentScrollPosition = 0;
193
+ $(document).scroll(function(){
194
+ currentScrollPosition = $(this).scrollTop();
195
+ });
196
+ window.onhashchange = function() {
197
+ methods.loadGalleryDeepLink();
198
+ };
199
+
200
+ $("input, textarea").focus(function(){
201
+ $(document).scrollTop(currentScrollPosition);
202
+ });
203
+
204
  var browser_class = '';
205
  if (prototypes.isIEBrowser()) {
206
  if (prototypes.isIEBrowser() < 8) {
213
  browser_class += ' istouch';
214
  }
215
 
216
+ $('.gmPhantom_thumbsWrapper', Container).addClass(browser_class);
217
+ if (opt.thumbsInfo == 'tooltip' && !prototypes.isTouchDevice()) {
218
+ $('.gmPhantom_Container', Container).append('<div class="gmPhantom_Tooltip"></div>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  }
220
+
221
+ methods.initSettings();
222
+
223
+ var thumbs_wrapper = $('.gmPhantom_thumbsWrapper', Container);
224
+ thumbs_wrapper.magnificPopup({
225
+ type: 'image',
226
+ delegate: '.gmPhantom_ThumbContainer',
227
+ preloader: true,
228
+ closeBtnInside: false,
229
+ fixedContentPos: 'auto',
230
+ fixedBgPos: true,
231
+ overflowY: '',
232
+ closeMarkup: '<div title="%title%" class="mfp-button mfp-close">&#215;</div>',
233
+ tLoading: '', // remove text from preloader
234
+ callbacks: {
235
+ elementParse: function(item) {
236
+ // Function will fire for each target element
237
+ // "item.el" is a target DOM element (if present)
238
+ // "item.src" is a source that you may modify
239
+ var no = parseInt(item.el.data('no'));
240
+ item.no = no;
241
+ item.gm_id = IDs[no];
242
+ item.gm_type = Types[no];
243
+ item.gm_ext = Extentions[no];
244
+ if('image' == item.gm_type) {
245
+ item.src = Images[no];
246
+ } else {
247
+ item.src = Sources[no];
248
+ }
249
+ item.title = CaptionTitle[no];
250
+ item.description = CaptionText[no];
251
+ item.gm_link = Links[no];
252
+ item.gm_link_target = LinksTarget[no];
253
+
254
+ item.views = ViewsCount[no];
255
+ item.likes = LikesCount[no];
256
+
257
+ if(!Storage[item.gm_id]){
258
+ Storage[item.gm_id] = {}
259
+ }
260
+ if (Storage[item.gm_id].status) {
261
+ item.viewed = true;
262
+ if ('liked' == Storage[item.gm_id].status) {
263
+ item.liked = true;
264
+ } else {
265
+ item.liked = false;
266
+ }
267
+ }
268
+ },
269
+ markupParse: function(template, values, item) {
270
+ if(item.gm_link) {
271
+ values.title = '<a href="' + item.gm_link + '" target="' + item.gm_link_target + '">' + item.title + '</a>';
272
+ } else {
273
+ values.title = item.title;
274
+
275
+ }
276
+ values.description = item.description;
277
+ },
278
+
279
+ imageLoadComplete: function() {
280
+ var self = this;
281
+ setTimeout(function() {
282
+ self.wrap.addClass('mfp-image-loaded');
283
+ }, 16);
284
+ },
285
+ open: function() {
286
+ $(document.body).addClass('mfp-gmedia-open');
287
+ itemLoaded = true;
288
+ if(opt.commentsEnabled){
289
+ this.wrap.on('click.gmCloseComments', '.mfp-img--comments-div', function() {
290
+ $('#mfp_comments_' + ID, this.wrap).trigger('click');
291
+ return false;
292
+ });
293
+ }
294
+ },
295
+ close: function() {
296
+ $(document.body).removeClass('mfp-gmedia-open');
297
+ if('image' != this.currItem.gm_type) {
298
+ $(document.body).removeClass('mfp-zoom-out-cur');
299
+ this.wrap.removeClass('mfp-iframe-loaded');
300
+ }
301
+ this.wrap.removeClass('mfp-image-loaded');
302
+
303
+ if(opt.commentsEnabled){
304
+ this.wrap.off('click.gmCloseComments');
305
+ }
306
+ if(opt.deepLinks) {
307
+ var hash = '#!',
308
+ url = ('' + window.location).split('#')[0] + hash;
309
+ if(!!(window.history && window.history.replaceState)) {
310
+ window.history.replaceState({}, document.title, url);
311
+ } else {
312
+ location.replace(url);
313
+ }
314
+ }
315
+ this.contentContainer.attr('data-gmtype', this.currItem.gm_type).attr('data-ext', this.currItem.gm_ext);
316
+ $('#wpadminbar').css({'z-index':''});
317
+ itemLoaded = false;
318
+ $(window).scrollTop(scrollTop);
319
+ },
320
+ beforeOpen: function() {
321
+ $('#wpadminbar').css({'z-index':1000});
322
+ $(this.wrap).attr('id', 'mfp_gm_' + ID);
323
+ $(this.bgOverlay).attr('id', 'mfp_gm_' + ID + '_bg');
324
+ if(opt.lightbox800HideArrows) {
325
+ this.wrap.addClass('mfp800-hide-arrows');
326
+ }
327
+ if(opt.mfp_css && !$('#mfp_css_' + ID, this.wrap).length) {
328
+ this.wrap.append('<style id="mfp_css_' + ID + '">' + opt.mfp_css + '</style>');
329
+ }
330
+ scrollTop = $(window).scrollTop();
331
+ },
332
+ change: function() {
333
+ if(opt.deepLinks) {
334
+ var hash = "#!gallery-" + ID + '-' + this.currItem.gm_id,
335
+ url = ('' + window.location).split('#')[0] + hash;
336
+ if(!!(window.history && window.history.replaceState)) {
337
+ window.history.replaceState({}, document.title, url);
338
+ } else {
339
+ location.replace(url);
340
+ }
341
+ }
342
+ this.contentContainer.attr('data-gmtype', this.currItem.gm_type).attr('data-ext', this.currItem.gm_ext);
343
+ if(opt.commentsEnabled) {
344
+ this.wrap.removeClass('mfp-comments-open mfp-comments-loaded');
345
+ $('.mfp-comments-wrapper', this.contentContainer).css({height: ''}).empty();
346
+ }
347
+ if(opt.likesEnabled) {
348
+ this.wrap.removeClass('phantom-gmedia-liked');
349
+ }
350
+ clearTimeout(timeout);
351
+ if('image' != this.currItem.gm_type) {
352
+ $(document.body).addClass('mfp-zoom-out-cur');
353
+ var self = this;
354
+ setTimeout(function() {
355
+ self.wrap.addClass('mfp-iframe-loaded');
356
+ }, 16);
357
+ }
358
+ },
359
+ afterChange: function() {
360
+ if(opt.socialShareEnabled) {
361
+ methods.initSocialShare(this.currItem.no, this);
362
+ }
363
+ if(opt.viewsEnabled) {
364
+ methods.initViews(this.currItem.no, this);
365
+ }
366
+ if(opt.likesEnabled) {
367
+ methods.initLikes(this.currItem.no, this);
368
+ }
369
+ if(opt.commentsEnabled) {
370
+ methods.initComments(this.currItem.no, this);
371
+ }
372
+ var self = this;
373
+ timeout = setTimeout(function () {
374
+ methods.viewLike(self.currItem);
375
+ }, 1000);
376
+ if (Storage[this.currItem.gm_id] && Storage[this.currItem.gm_id].status && 'liked' == Storage[this.currItem.gm_id].status) {
377
+ this.wrap.addClass('phantom-gmedia-liked');
378
+ } else {
379
+ this.wrap.removeClass('phantom-gmedia-liked');
380
+ }
381
+ },
382
+ updateStatus: function(data) {
383
+ //console.log(data);
384
+ //if(data.status == 'ready') {}
385
+ }
386
+ },
387
+ image: {
388
+ markup: ''+
389
+ '<div class="mfp-figure">' +
390
+ ' <div class="mfp-close"></div>' +
391
+ ' <figure>' +
392
+ ' <div class="mfp-img"></div>' +
393
+ ' <figcaption>' +
394
+ ' <div class="mfp-bottom-bar">' +
395
+ ' <div class="mfp-title"></div>' +
396
+ ' <div class="mfp-description"></div>' +
397
+ ' <div class="mfp-counter"></div>' +
398
+ ' </div>' +
399
+ ' </figcaption>' +
400
+ ' </figure>' +
401
+ '</div>' +
402
+ '<div class="mfp-comments-container">' +
403
+ ' <div class="mfp-comments-content"><div class="mfp-comments-wrapper"></div></div>' +
404
+ '</div>' +
405
+ '<div class="mfp-prevent-close mfp-buttons-bar"></div>'
406
+ },
407
+ iframe: {
408
+ markup: ''+
409
+ '<div class="mfp-iframe-wrapper">' +
410
+ ' <div class="mfp-close"></div>' +
411
+ ' <div class="mfp-iframe-scaler">' +
412
+ ' <iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowtransparency="true" allowfullscreen></iframe>' +
413
+ ' </div>' +
414
+ ' <div class="mfp-bottom-bar gm-iframe-bottom-bar">' +
415
+ ' <div class="mfp-title"></div>' +
416
+ ' <div class="mfp-description"></div>' +
417
+ ' <div class="mfp-counter"></div>' +
418
+ ' </div>' +
419
+ '</div>' +
420
+ '<div class="mfp-comments-container">' +
421
+ ' <div class="mfp-comments-content"><div class="mfp-comments-wrapper"></div></div>' +
422
+ '</div>' +
423
+ '<div class="mfp-prevent-close mfp-buttons-bar"></div>'
424
+ },
425
+ gallery: {
426
+ enabled: true,
427
+ arrowMarkup: '<div title="%title%" type="button" class="mfp-button mfp-arrow mfp-arrow-%dir%"></div>',
428
+ tCounter: '%curr% / %total%'
429
+ },
430
+
431
+ mainClass: 'mfp-zoom-in',
432
+ removalDelay: 500, //delay removal by X to allow out-animation
433
+
434
+ });
435
+
436
+ methods.loadGalleryDeepLink();
437
+
438
+ },
439
+ loadGalleryDeepLink: function() {
440
+ var prefix = "#!gallery-";
441
+ var h = location.hash;
442
+ if(h.indexOf(prefix) === 0) {
443
+ h = h.substr(prefix.length).split('-');
444
+ if(h[0] && parseInt(h[0]) == ID) {
445
+ $(document).scrollTop($(Container).offset().top);
446
+ if(h[1]) {
447
+ startWith = IDs.indexOf(h[1]);
448
+ } else {
449
+ startWith = 0;
450
+ }
451
+ if(-1 !== startWith) {
452
+ $('.gmPhantom_thumbsWrapper', Container).magnificPopup("open", startWith);
453
+ }
454
+ }
455
  }
456
+ },
457
+ initSocialShare: function(no, mfp) {
458
+ var share_buttons = ''+
459
+ '<div class="mfp-prevent-close mfp-button mfp-share mfp-gmedia-stuff08" id="mfp_share_' + ID + '">'+
460
+ ' <a class="mfp-prevent-close" title="Share">'+
461
+ ' <span class="mfp-prevent-click">'+
462
+ ' <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><symbol id="icon-share2" viewBox="0 0 1024 1024"><path class="path1" d="M864 704c-45.16 0-85.92 18.738-115.012 48.83l-431.004-215.502c1.314-8.252 2.016-16.706 2.016-25.328s-0.702-17.076-2.016-25.326l431.004-215.502c29.092 30.090 69.852 48.828 115.012 48.828 88.366 0 160-71.634 160-160s-71.634-160-160-160-160 71.634-160 160c0 8.622 0.704 17.076 2.016 25.326l-431.004 215.504c-29.092-30.090-69.852-48.83-115.012-48.83-88.366 0-160 71.636-160 160 0 88.368 71.634 160 160 160 45.16 0 85.92-18.738 115.012-48.828l431.004 215.502c-1.312 8.25-2.016 16.704-2.016 25.326 0 88.368 71.634 160 160 160s160-71.632 160-160c0-88.364-71.634-160-160-160z"></path></symbol></svg>'+
463
+ ' <svg class="gmPhantom_svgicon"><use xlink:href="#icon-share2"/></svg>'+
464
+ ' </span>'+
465
+ ' </a>'+
466
+ ' <ul class="mfp-prevent-close mfp-share_sharelizers">'+
467
+ ' <li><a class="mfp-prevent-close mfp-share_facebook mfp-share_sharelizer">Facebook</a></li>'+
468
+ ' <li><a class="mfp-prevent-close mfp-share_twitter mfp-share_sharelizer">Twitter</a></li>'+
469
+ ' <li><a class="mfp-prevent-close mfp-share_pinterest mfp-share_sharelizer">Pinterest</a></li>'+
470
+ ' <li><a class="mfp-prevent-close mfp-share_google mfp-share_sharelizer">Google+</a></li>'+
471
+ ' <li><a class="mfp-prevent-close mfp-share_stumbleupon mfp-share_sharelizer">StumbleUpon</a></li>'+
472
+ ' </ul>'+
473
+ '</div>';
474
+
475
+ var mfp_share = $(share_buttons);
476
+ mfp_share.on('click', function(){
477
+ $(this).toggleClass('mfp-share_open');
478
+ });
479
+
480
+ $('.mfp-share_sharelizer', mfp_share).on('click', function () {
481
+ var sharelink,
482
+ title = CaptionTitle[no],
483
+ imgsrc = Images[no],
484
+ url = window.location.href;
485
+ if(!opt.deepLinks) {
486
+ var hash = "#!gallery-" + ID + '-' + IDs[no];
487
+ url = ('' + window.location).split('#')[0] + hash;
488
+ }
489
+ if(opt.share_post_link){
490
+ url = PostLinks[no];
491
+ }
492
+ if ($(this).hasClass('mfp-share_twitter')) {
493
+ sharelink = 'https://twitter.com/home?status=' + encodeURIComponent(title + ' ' + url);
494
+ window.open(sharelink, '_blank');
495
+ }
496
+ if ($(this).hasClass('mfp-share_facebook')) {
497
+ sharelink = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(url);
498
+ window.open(sharelink, '_blank');
499
+ }
500
+ if ($(this).hasClass('mfp-share_pinterest')) {
501
+ sharelink = 'https://pinterest.com/pin/create/button/?url=' + encodeURIComponent(url) + '&media=' + encodeURIComponent(imgsrc) + '&description=' + encodeURIComponent(title);
502
+ window.open(sharelink, '_blank');
503
+ }
504
+ if ($(this).hasClass('mfp-share_google')) {
505
+ sharelink = 'https://plus.google.com/share?url=' + encodeURIComponent(url);
506
+ window.open(sharelink, '_blank');
507
+ }
508
+ if ($(this).hasClass('mfp-share_stumbleupon')) {
509
+ sharelink = 'http://www.stumbleupon.com/submit?url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title);
510
+ window.open(sharelink, '_blank');
511
+ }
512
+ });
513
+
514
+ var share_div = mfp.wrap.find('#mfp_share_' + ID);
515
+ if(!share_div.length) {
516
+ $('.mfp-buttons-bar', mfp.wrap).append(mfp_share);
517
+ } else {
518
+ $(share_div).replaceWith(mfp_share);
519
  }
520
+ },
521
+ initComments: function(no, mfp) {
522
+ var comments_button = ''+
523
+ '<div class="mfp-prevent-close mfp-button mfp-comments" id="mfp_comments_' + ID + '">'+
524
+ ' <a class="mfp-prevent-close" title="Comments"><span class="mfp-prevent-close mfp-comments-count">' + CommentsCount[no] + '</span>'+
525
+ ' <span class="mfp-prevent-click mfp_comments_icon">'+
526
+ ' <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><symbol id="icon-bubbles2" viewBox="0 0 1152 1024"><path class="path1" d="M480 0v0c265.096 0 480 173.914 480 388.448s-214.904 388.448-480 388.448c-25.458 0-50.446-1.62-74.834-4.71-103.106 102.694-222.172 121.108-341.166 123.814v-25.134c64.252-31.354 116-88.466 116-153.734 0-9.106-0.712-18.048-2.030-26.794-108.558-71.214-177.97-179.988-177.97-301.89 0-214.534 214.904-388.448 480-388.448zM996 870.686c0 55.942 36.314 104.898 92 131.772v21.542c-103.126-2.318-197.786-18.102-287.142-106.126-21.14 2.65-42.794 4.040-64.858 4.040-95.47 0-183.408-25.758-253.614-69.040 144.674-0.506 281.26-46.854 384.834-130.672 52.208-42.252 93.394-91.826 122.414-147.348 30.766-58.866 46.366-121.582 46.366-186.406 0-10.448-0.45-20.836-1.258-31.168 72.57 59.934 117.258 141.622 117.258 231.676 0 104.488-60.158 197.722-154.24 258.764-1.142 7.496-1.76 15.16-1.76 22.966z"></path></symbol></svg>'+
527
+ ' <svg class="gmPhantom_svgicon"><use xlink:href="#icon-bubbles2"/></svg>'+
528
+ ' </span>'+
529
+ ' </a>'+
530
+ '</div>';
531
+ var mfp_comments = $(comments_button);
532
+ mfp_comments.on('click', function(){
533
+ var comments_wrapper = $('.mfp-comments-wrapper', mfp.contentContainer);
534
+ if(mfp.wrap.hasClass('mfp-comments-open')) {
535
+ comments_wrapper.css({height: ''});
536
+ $('figure > img', mfp.wrap).removeClass('mfp-img--comments-div').addClass('mfp-img');
537
+ mfp.wrap.removeClass('mfp-comments-open');
538
+ if($(window).width() <= 800) {
539
+ $('body').delay(200).animate({scrollTop: $('#mfp_gm_' + ID).offset().top}, 400);
540
+ } else {
541
+ $(window).scrollTop($('#mfp_gm_' + ID).offset().top);
542
+ }
543
+ } else {
544
+ comments_wrapper.css({height: $('iframe', comments_wrapper).height()});
545
+ $('figure > img', mfp.wrap).removeClass('mfp-img').addClass('mfp-img--comments-div');
546
+ mfp.wrap.addClass('mfp-comments-open')
547
+ if(!mfp.wrap.hasClass('mfp-comments-loaded')) {
548
+ methods.loadComments(no, mfp);
549
+ }
550
+ if($(window).width() <= 800){
551
+ $('body').delay(200).animate({scrollTop: ($('.mfp-comments-container', '#mfp_gm_'+ID).offset().top - 250)}, 400);
552
+ }
553
+ }
554
+ });
555
 
556
+ var comments_div = $(mfp.wrap).find('#mfp_comments_' + ID);
557
+ if(!comments_div.length) {
558
+ $('.mfp-buttons-bar', mfp.wrap).append(mfp_comments);
559
+ } else {
560
+ $(comments_div).replaceWith(mfp_comments);
561
  }
562
 
563
+ },
564
+ initLikes: function(no, mfp) {
565
+ if(mfp.currItem.liked){
566
+ mfp.wrap.addClass('phantom-gmedia-liked');
567
+ }
568
+
569
+ var likes = ''+
570
+ '<div class="mfp-prevent-close mfp-button mfp-likes" id="mfp_likes_' + ID + '">'+
571
+ ' <a class="mfp-prevent-close"><span class="mfp-prevent-close mfp-likes-count">' + LikesCount[no] + '</span>'+
572
+ ' <span class="mfp-prevent-click mfp_likes_icon">'+
573
+ ' <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><symbol id="icon-heart" viewBox="0 0 1024 1024"><path class="path1" d="M755.188 64c-107.63 0-200.258 87.554-243.164 179-42.938-91.444-135.578-179-243.216-179-148.382 0-268.808 120.44-268.808 268.832 0 301.846 304.5 380.994 512.022 679.418 196.154-296.576 511.978-387.206 511.978-679.418 0-148.392-120.43-268.832-268.812-268.832z"></path></symbol></svg>'+
574
+ ' <svg class="gmPhantom_svgicon"><use xlink:href="#icon-heart"/></svg>'+
575
+ ' </span>'+
576
+ ' </a>'+
577
+ '</div>';
578
+ var likes_obj = $(likes);
579
+ likes_obj.on('click', function(){
580
+ methods.viewLike(mfp.currItem, true);
581
+ mfp.wrap.addClass('phantom-gmedia-liked');
582
+ $('.mfp-likes-count', this).text(LikesCount[no]);
583
+ });
584
 
585
+ var likes_div = $(mfp.wrap).find('#mfp_likes_' + ID);
586
+ if(!likes_div.length) {
587
+ $('.mfp-buttons-bar', mfp.wrap).append(likes_obj);
588
  } else {
589
+ $(likes_div).replaceWith(likes_obj);
590
  }
591
+
592
  },
593
+ initViews: function(no, mfp) {
594
+ var views = ''+
595
+ '<div class="mfp-prevent-close mfp-button mfp-views" id="mfp_views_' + ID + '">'+
596
+ ' <span class="mfp-prevent-close mfp-prevent-click"><span class="mfp-prevent-close mfp-views-count">' + ViewsCount[no] + '</span>'+
597
+ ' <span class="mfp-prevent-close mfp-prevent-click mfp_views_icon">'+
598
+ ' <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><symbol id="icon-eye" viewBox="0 0 1024 1024"><path class="path1" d="M512 192c-223.318 0-416.882 130.042-512 320 95.118 189.958 288.682 320 512 320 223.312 0 416.876-130.042 512-320-95.116-189.958-288.688-320-512-320zM764.45 361.704c60.162 38.374 111.142 89.774 149.434 150.296-38.292 60.522-89.274 111.922-149.436 150.296-75.594 48.218-162.89 73.704-252.448 73.704-89.56 0-176.858-25.486-252.452-73.704-60.158-38.372-111.138-89.772-149.432-150.296 38.292-60.524 89.274-111.924 149.434-150.296 3.918-2.5 7.876-4.922 11.86-7.3-9.96 27.328-15.41 56.822-15.41 87.596 0 141.382 114.616 256 256 256 141.382 0 256-114.618 256-256 0-30.774-5.452-60.268-15.408-87.598 3.978 2.378 7.938 4.802 11.858 7.302v0zM512 416c0 53.020-42.98 96-96 96s-96-42.98-96-96 42.98-96 96-96 96 42.982 96 96z"></path></symbol></svg>'+
599
+ ' <svg class="gmPhantom_svgicon"><use xlink:href="#icon-eye"/></svg>'+
600
+ ' </span></span>'+
601
+ '</div>';
602
+
603
+ var views_div = $(mfp.wrap).find('#mfp_views_' + ID);
604
+ if(!views_div.length) {
605
+ $('.mfp-buttons-bar', mfp.wrap).append(views);
606
+ } else {
607
+ $(views_div).replaceWith(views);
608
+ }
609
+
610
+ },
611
+ loadComments: function(no, mfp){
612
+ var comments_content = $('.mfp-comments-content', mfp.contentContainer),
613
+ comments_wrapper = $('.mfp-comments-wrapper', comments_content);
614
+ comments_wrapper.empty();
615
+ mfp.wrap.removeClass('mfp-comments-loaded').addClass('mfp-comments-loading');
616
+ if (GmediaGallery) {
617
+ opt.ajax_actions['comments']['data']['post_id'] = Post_IDs[no];
618
+ $.ajax({
619
+ type : "post",
620
+ dataType : "json",
621
+ url: GmediaGallery.ajaxurl,
622
+ data: {action: opt.ajax_actions['comments']['action'], _ajax_nonce: GmediaGallery.nonce, data: opt.ajax_actions['comments']['data']},
623
+ }).done(function(data){
624
+ if(data.comments_count){
625
+ mfp.wrap.find('.mfp-comments-count').html(data.comments_count);
626
+ CommentsCount[no] = data.comments_count
627
+ }
628
+ if(data.content) {
629
+ $('.mfp-comments-wrapper', comments_content).html(data.content).find('iframe').on('load', function() {
630
+ mfp.wrap.removeClass('mfp-comments-loading').addClass('mfp-comments-loaded');
631
+ var body = this.contentWindow.document.body, html = this.contentWindow.document.documentElement;
632
+ var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
633
+ $(this).css({height: 20 + height, overflowY: 'hidden'}).parent().css({height: 20 + height});
634
+ this.contentWindow.onbeforeunload = function() {
635
+ mfp.wrap.removeClass('mfp-comments-loaded').addClass('mfp-comments-loading');
636
+ };
637
+ $.ajax({
638
+ type : "post",
639
+ dataType : "json",
640
+ url: GmediaGallery.ajaxurl,
641
+ data: {action: opt.ajax_actions['comments']['action'], _ajax_nonce: GmediaGallery.nonce, data: opt.ajax_actions['comments']['data']},
642
+ }).done(function(data){
643
+ if(data.comments_count){
644
+ mfp.wrap.find('.mfp-comments-count').html(data.comments_count);
645
+ CommentsCount[no] = data.comments_count
646
+ }
647
+ });
648
+ });
649
+ }
650
+ }).fail(function(){
651
+ mfp.wrap.removeClass('mfp-comments-loading');
652
+ });
653
+ }
654
+ },
655
+ viewLike: function (item, like) {
656
+ var id = item.gm_id;
657
+ if(!Storage[id]){
658
+ Storage[id] = {}
659
+ }
660
+ if (Storage[id].status) {
661
+ item.viewed = true;
662
+ if ('liked' == Storage[id].status) {
663
+ item.liked = true;
664
+ }
665
+ }
666
+ if (!item.viewed) {
667
+ item.viewed = true;
668
+ ViewsCount[item.no] += 1;
669
+ Storage[id].status = 'viewed';
670
+ sessionStorage.setItem(elID, JSON.stringify(Storage));
671
+ if (GmediaGallery.ajaxurl) {
672
+ $.ajax({
673
+ type : "post",
674
+ dataType : "json",
675
+ url: GmediaGallery.ajaxurl,
676
+ data: {action: 'gmedia_module_interaction', hit: id}
677
+ }).done(function(r){
678
+ if(r.views){
679
+ item.views = ViewsCount[item.no] = r.views;
680
+ }
681
+ });
682
+ }
683
+ }
684
+ if (like && !item.liked) {
685
+ item.liked = true;
686
+ item.likes += 1;
687
+ LikesCount[item.no] = item.likes;
688
+ Storage[id].status = 'liked';
689
+ sessionStorage.setItem(elID, JSON.stringify(Storage));
690
+ if (GmediaGallery.ajaxurl) {
691
+ $.ajax({
692
+ type : "post",
693
+ dataType : "json",
694
+ url: GmediaGallery.ajaxurl,
695
+ data: {action: 'gmedia_module_interaction', hit: id, vote: 1}
696
+ }).done(function(r){
697
+ if(r.likes){
698
+ item.likes = LikesCount[item.no] = r.likes;
699
+ }
700
+ });
701
+ }
702
+ }
703
+ },
704
+ initSettings: function() {// Init Settings
705
+ if (window.sessionStorage) {
706
+ Storage = sessionStorage.getItem(elID);
707
+ if (Storage) {
708
+ Storage = JSON.parse(Storage);
709
+ } else {
710
+ Storage = {};
711
+ }
712
+ }
713
  methods.initContainer();
714
  methods.initThumbs();
715
+ if(opt.thumbsInfo == 'tooltip' && !prototypes.isTouchDevice()) {
716
  methods.initTooltip();
717
  }
 
 
718
 
719
  },
720
+ initRP: function() {// Init Resize & Positioning
721
  var rrr = methods.rpResponsive();
722
+ if(!rrr && 50 > cc) {
723
  cc++;
724
  clearTimeout(timeout);
725
+ timeout = setTimeout(function() {
726
  methods.initRP();
727
  }, 100);
728
  } else {
729
  cc = 0;
730
  methods.rpContainer();
731
  methods.rpThumbs();
 
 
 
 
 
 
 
 
 
 
 
732
  }
733
  },
734
+ rpResponsive: function() {
735
  var hiddenBustedItems = prototypes.doHideBuster($(Container));
736
 
737
+ if($(window).width() <= 640) {
738
+ $('.gmPhantom_Container', Container).addClass('gmPhantom_MobileView');
739
+ opt.thumbWidth = opt.thumbWidthMobile;
740
+ opt.thumbHeight = opt.thumbHeightMobile;
741
+ opt.ratio = opt.mratio;
742
+ } else {
743
+ $('.gmPhantom_Container', Container).removeClass('gmPhantom_MobileView');
744
  opt.thumbWidth = opt.thumbWidthDesktop;
745
  opt.thumbHeight = opt.thumbHeightDesktop;
746
+ opt.ratio = opt.dratio;
747
  }
748
 
749
  opt.width = $(Container).width();
 
750
  prototypes.undoHideBuster(hiddenBustedItems);
751
 
752
  return opt.width;
753
  },
754
 
755
+ initContainer: function() {// Init Container
756
+ $('.gmPhantom_Container', Container).removeClass('delay');
 
 
757
  $('.gmPhantom_Container', Container).css({'display': 'block', 'text-align': opt.thumbsAlign});
758
 
759
+ if(opt.maxheight === 0) {
760
  $('.gmPhantom_Container', Container).css('overflow', 'visible');
761
  }
762
  $('.gmPhantom_Background', Container).css('opacity', opt.bgAlpha / 100);
763
+ if(opt.bgAlpha !== 0) {
764
  $('.gmPhantom_Background', Container).css('background-color', '#' + opt.bgColor);
765
  }
766
  $('.gmPhantom_thumbsWrapper', Container).css({
769
  'padding-left': opt.thumbsHorizontalPadding,
770
  'padding-right': opt.thumbsHorizontalPadding
771
  });
772
+ if(opt.thumbsAlign == 'left') {
773
  $('.gmPhantom_thumbsWrapper', Container).css({'margin-left': 0});
774
+ } else if(opt.thumbsAlign == 'right') {
775
  $('.gmPhantom_thumbsWrapper', Container).css({'margin-right': 0});
776
  }
777
  methods.rpContainer();
778
  },
779
+ rpContainer: function() {// Resize & Position Container
780
  $('.gmPhantom_Container', Container).width(opt.width);
781
+ if(opt.maxheight === 0) {
782
  $('.gmPhantom_Container', Container).css('height', 'auto');
783
  $('.gmPhantom_thumbsWrapper', Container).css('height', 'auto');
784
  } else {
786
  }
787
  },
788
 
789
+ initThumbs: function() {//Init Thumbnails
790
+ if(opt.maxheight === 0) {
791
  $('.gmPhantom_thumbsWrapper', Container).css({'overflow': 'visible', 'position': 'relative'});
792
  }
793
 
794
  var thumb_container = $('.gmPhantom_ThumbContainer', Container);
795
+ if(opt.thumbsInfo == 'tooltip') {
796
+ if(!prototypes.isTouchDevice()) {
797
+ thumb_container.hover(function() {
 
 
 
 
 
 
798
  var no = $(this).data('no');
799
  methods.showTooltip(no);
800
+ },
801
+ function() {
 
 
 
 
 
802
  $('.gmPhantom_Tooltip', Container).css('display', 'none');
803
+ });
804
+ } else {
805
+ $('.gmPhantom_thumbsWrapper', Container).removeClass('gmPhantom_LabelTolltip').addClass('gmPhantom_LabelInside');
 
 
 
 
 
 
 
 
 
 
806
  }
807
  }
808
 
809
+ thumb_container.click(function(e) {
810
  var no = $(this).data('no');
811
+ if(Links[no] !== '' && opt.thumb2link) {
812
+ e.stopPropagation();
 
813
  prototypes.openLink(Links[no], LinksTarget[no]);
814
  }
815
  });
816
+ $('.gmPhantom_Thumb', thumb_container).click(function(e) {
817
+ e.stopPropagation();
818
+ e.preventDefault();
819
+ $(this).parent().trigger('click');
820
  return false;
821
  });
822
+ $('.gmPhantom_ThumbLabel a', thumb_container).click(function(e) {
823
+ e.stopPropagation();
824
+ });
825
 
826
+ $('.gmPhantom_Thumb img', Container).each(function() {
827
+ var image = $(this);
828
+ var img_holder = image.closest('.gmPhantom_ThumbContainer');
829
+ image.css('opacity', 0);
830
+ var load_img = new Image();
831
+ $(load_img).load(function() {
832
+ img_holder.removeClass('gmPhantom_ThumbLoader');
833
+ image.animate({'opacity': opt.thumbAlpha}, 600, function(){
834
+ $(this).css({'opacity':''});
835
  });
836
+ }).attr('src', image.attr('src'));
837
  });
838
 
839
+ if(opt.maxheight !== 0) {
840
+ if(prototypes.isTouchDevice()) {
841
  prototypes.touchNavigation($('.gmPhantom_Container', Container), $('.gmPhantom_thumbsWrapper', Container));
842
  }
843
+ else if(opt.thumbsNavigation == 'mouse') {
844
  methods.moveThumbs();
845
  }
846
+ else if(opt.thumbsNavigation == 'scroll') {
847
  methods.initThumbsScroll();
848
  }
849
  }
850
 
851
  methods.rpThumbs();
852
  },
853
+ rpThumbs: function() {// Resize & Position Thumbnails
854
  var thumbW = opt.thumbWidth + opt.thumbBorderSize * 2 + opt.thumbPadding * 2,
855
  no = 0,
856
  hiddenBustedItems = prototypes.doHideBuster($(Container));
857
+ if(opt.initialHeight === 0 || (opt.initialCols === 0 && opt.initialRows === 0)) {
858
  opt.thumbCols = parseInt((opt.width + opt.thumbsSpacing - opt.thumbsHorizontalPadding * 2) / (thumbW + opt.thumbsSpacing));
859
  opt.thumbRows = parseInt(noItems / opt.thumbCols);
860
 
861
+ if(opt.thumbCols === 0) {
862
  opt.thumbCols = 1;
863
  }
864
 
865
+ if(opt.thumbRows * opt.thumbCols < noItems) {
866
  opt.thumbRows++;
867
  }
868
  } else {
869
+ if((opt.thumbRows * opt.thumbCols < noItems) && opt.thumbCols !== 0) {
870
+ if(noItems % opt.thumbCols === 0) {
871
  opt.thumbRows = noItems / opt.thumbCols;
872
  } else {
873
  opt.thumbRows = parseInt(noItems / opt.thumbCols) + 1;
874
  }
875
  } else {
876
+ if(noItems % opt.thumbRows === 0) {
877
  opt.thumbCols = noItems / opt.thumbRows;
878
  } else {
879
  opt.thumbCols = parseInt(noItems / opt.thumbRows) + 1;
880
  }
881
  }
882
  }
 
883
 
884
+ var thumbs_spacing = opt.thumbsSpacing;
885
+ if(0 == thumbs_spacing){
886
+ thumbs_spacing = -opt.thumbBorderSize;
887
+
888
+ }
889
+ $('.gmPhantom_ThumbContainer', Container).each(function() {
890
  no++;
891
 
892
+ $(this).css({'margin': ''});
893
+ if(thumbs_spacing) {
894
+ if(no > opt.thumbCols) {
895
+ $(this).css('margin-top', thumbs_spacing);
896
+ }
897
+ if(no % opt.thumbCols != 1 && opt.thumbCols != 1) {
898
+ $(this).css('margin-left', thumbs_spacing);
899
+ }
900
  }
901
+ if(no % opt.thumbCols === 0) {
902
  $(this).css('margin-right', '-1px');
903
  }
904
 
905
+ var img = $('.gmPhantom_Thumb > img', this);
906
+ var thumb_ratio = $(this).data('ratio');
907
+ if(opt.ratio < thumb_ratio){
908
+ img.attr('class', 'landscape').attr('style', 'margin:0 0 0 -' + Math.floor((opt.thumbHeight * thumb_ratio - opt.thumbWidth) / opt.thumbWidth * 50) + '%');
909
+ } else {
910
+ img.attr('class', 'portrait').attr('style', 'margin:-' + Math.floor((opt.thumbWidth / thumb_ratio - opt.thumbHeight) / opt.thumbHeight * 25) + '% 0 0 0');
911
+ }
912
+
913
  });
914
  var thumbs_el = $('.gmPhantom_thumbsWrapper', Container),
915
  thumbs_el_width = thumbW * opt.thumbCols + (opt.thumbCols - 1) * opt.thumbsSpacing,
916
  scrollbar_width = 0;
917
  thumbs_el.width(thumbs_el_width);
918
+ if(thumbs_el_width >= $('.gmPhantom_Container', Container).width()) {
919
  scrollbar_width = methods.scrollbarWidth();
920
  }
921
 
922
+ if(opt.initialHeight !== 0) {
923
  var thumbH = opt.thumbHeight + opt.thumbBorderSize * 2 + opt.thumbPadding * 2,
924
  thumbs_el_height = thumbH * opt.thumbRows + (opt.thumbRows - 1) * opt.thumbsSpacing;
925
+ $('.gmPhantom_thumbsWrapper', Container).height(thumbs_el_height + scrollbar_width);
 
 
 
 
 
926
 
927
+ if((opt.thumbsNavigation == 'mouse')) {
928
+ if($('.gmPhantom_Container', Container).width() > thumbs_el.outerWidth()) {
929
  thumbs_el.css('margin-left', ($('.gmPhantom_Container', Container).width() - thumbs_el.outerWidth()) / 2);
930
  } else {
931
  thumbs_el.css('margin-left', 0);
933
  thumbs_el.css('margin-top', 0);
934
  }
935
 
936
+ if(opt.thumbsNavigation == 'scroll' && typeof(jQuery.fn.jScrollPane) != 'undefined') {
937
  $('.gmPhantom_Container .jspContainer', Container).width($('.gmPhantom_thumbsWrapper', Container).width());
938
  }
939
  }
942
 
943
  prototypes.undoHideBuster(hiddenBustedItems);
944
  },
945
+ moveThumbs: function() {// Init thumbnails move
946
  var thumbs_el = $('.gmPhantom_thumbsWrapper', Container);
947
+ $('.gmPhantom_Container', Container).mousemove(function(e) {
948
+ if(itemLoaded) {
949
  return;
950
  }
951
  var thumbW, thumbH, mousePosition, thumbsPosition;
952
 
953
+ if(thumbs_el.outerWidth() > $(this).width()) {
954
  thumbW = opt.thumbWidth + opt.thumbBorderSize * 2 + opt.thumbPadding * 2 + opt.thumbsSpacing - opt.thumbsSpacing / opt.thumbRows + opt.thumbsHorizontalPadding / opt.thumbCols;
955
  mousePosition = e.clientX - $(this).offset().left + parseInt($(this).css('margin-left')) + $(document).scrollLeft();
956
  thumbsPosition = 0 - (mousePosition - thumbW) * (thumbs_el.outerWidth() - $(this).width()) / ($(this).width() - 2 * thumbW);
957
+ if(thumbsPosition < (-1) * (thumbs_el.outerWidth() - $(this).width())) {
958
  thumbsPosition = (-1) * (thumbs_el.outerWidth() - $(this).width());
959
  }
960
+ if(thumbsPosition > 0) {
961
  thumbsPosition = 0;
962
  }
963
  thumbs_el.css('margin-left', thumbsPosition);
964
  //thumbs_el.animate({'margin-left': thumbsPosition}, { duration: 200, queue: false });
965
  }
966
 
967
+ if(thumbs_el.outerHeight() > $(this).height()) {
968
  thumbH = opt.thumbHeight + opt.thumbBorderSize * 2 + opt.thumbPadding * 2 + opt.thumbsSpacing - opt.thumbsSpacing / opt.thumbRows + opt.thumbsVerticalPadding / opt.thumbRows;
969
  mousePosition = e.clientY - $(this).offset().top + parseInt($(this).css('margin-top')) + $(document).scrollTop();
970
  thumbsPosition = 0 - (mousePosition - thumbH) * (thumbs_el.outerHeight() - $(this).height()) / ($(this).height() - 2 * thumbH);
971
+ if(thumbsPosition < (-1) * (thumbs_el.outerHeight() - $(this).height())) {
972
  thumbsPosition = (-1) * (thumbs_el.outerHeight() - $(this).height());
973
  }
974
+ if(thumbsPosition > 0) {
975
  thumbsPosition = 0;
976
  }
977
  thumbs_el.css('margin-top', thumbsPosition);
979
  }
980
  });
981
  },
982
+ initThumbsScroll: function() {//Init Thumbnails Scroll
983
+ if(typeof(jQuery.fn.jScrollPane) == 'undefined') {
984
  $('.gmPhantom_Container', Container).css('overflow', 'auto');
985
  } else {
986
+ setTimeout(function() {
987
  $('.gmPhantom_Container', Container).jScrollPane({autoReinitialise: true});
988
  }, 10);
989
  }
990
  },
991
+ scrollbarWidth: function() {
992
  var div = $('<div style="position:absolute;left:-200px;top:-200px;width:50px;height:50px;overflow:scroll"><div>&nbsp;</div></div>').appendTo('body'),
993
  width = 50 - div.children().innerWidth();
994
  div.remove();
995
  return width;
996
  },
997
+ initTooltip: function() {// Init Tooltip
998
+ $('.gmPhantom_ThumbContainer', Container).on('mouseover mousemove', function(e) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
999
  var thumbs_wrapper = $('.gmPhantom_thumbsWrapper', Container),
1000
  mousePositionX = e.clientX - $(thumbs_wrapper).offset().left + parseInt($(thumbs_wrapper).css('margin-left')) + $(document).scrollLeft(),
1001
  mousePositionY = e.clientY - $(thumbs_wrapper).offset().top + parseInt($(thumbs_wrapper).css('margin-top')) + $(document).scrollTop();
1004
  $('.gmPhantom_Tooltip', Container).css('top', mousePositionY - $('.gmPhantom_Tooltip', Container).height() - 15);
1005
  });
1006
  },
1007
+ showTooltip: function(no) {// Resize, Position & Display the Tooltip
1008
  var HTML = [];
1009
  HTML.push(CaptionTitle[no]);
1010
  HTML.push('<div class="gmPhantom_Tooltip_ArrowBorder"></div>');
1011
  HTML.push('<div class="gmPhantom_Tooltip_Arrow"></div>');
1012
  $('.gmPhantom_Tooltip', Container).html(HTML.join(""));
1013
+ if(opt.tooltipBgColor != 'css') {
 
1014
  $('.gmPhantom_Tooltip', Container).css('background-color', '#' + opt.tooltipBgColor);
1015
  $('.gmPhantom_Tooltip_Arrow', Container).css('border-top-color', '#' + opt.tooltipBgColor);
1016
  }
1017
+ if(opt.tooltipStrokeColor != 'css') {
1018
  $('.gmPhantom_Tooltip', Container).css('border-color', '#' + opt.tooltipStrokeColor);
1019
  $('.gmPhantom_Tooltip_ArrowBorder', Container).css('border-top-color', '#' + opt.tooltipStrokeColor);
1020
  }
1021
+ if(opt.tooltipTextColor != 'css') {
1022
  $('.gmPhantom_Tooltip', Container).css('color', '#' + opt.tooltipTextColor);
1023
  }
1024
+ if(CaptionTitle[no] !== '') {
1025
  $('.gmPhantom_Tooltip', Container).css('display', 'block');
1026
  }
1027
  }
1032
  var myNav = navigator.userAgent.toLowerCase();
1033
  return (myNav.indexOf('msie') == -1) ? false : parseInt(myNav.split('msie')[1]);
1034
  },
1035
+ isTouchDevice: function() {// Detect Touchscreen devices
1036
  return 'ontouchend' in document;
1037
  },
1038
+ touchNavigation: function(parent, child) {// One finger Navigation for touchscreen devices
1039
  var prevX, prevY, currX, currY, touch, moveTo, thumbsPositionX, thumbsPositionY,
1040
  thumbW = opt.thumbWidth + 2 * opt.thumbPadding + 2 * opt.thumbBorderSize,
1041
  thumbH = opt.thumbHeight + 2 * opt.thumbPadding + 2 * opt.thumbBorderSize;
1042
 
1043
 
1044
+ parent.bind('touchstart', function(e) {
1045
  touch = e.originalEvent.touches[0];
1046
  prevX = touch.clientX;
1047
  prevY = touch.clientY;
1048
  });
1049
 
1050
+ parent.bind('touchmove', function(e) {
1051
  touch = e.originalEvent.touches[0];
1052
  currX = touch.clientX;
1053
  currY = touch.clientY;
1054
+ thumbsPositionX = currX > prevX? parseInt(child.css('margin-left')) + (currX - prevX) : parseInt(child.css('margin-left')) - (prevX - currX);
1055
+ thumbsPositionY = currY > prevY? parseInt(child.css('margin-top')) + (currY - prevY) : parseInt(child.css('margin-top')) - (prevY - currY);
1056
 
1057
+ if(thumbsPositionX < (-1) * (child.outerWidth() - parent.width())) {
1058
+ thumbsPositionX = (-1) * (child.outerWidth() - parent.width());
1059
  }
1060
+ else if(thumbsPositionX > 0) {
1061
  thumbsPositionX = 0;
1062
  }
1063
  else {
1064
  e.preventDefault();
1065
  }
1066
 
1067
+ if(thumbsPositionY < (-1) * (child.outerHeight() - parent.height())) {
1068
+ thumbsPositionY = (-1) * (child.outerHeight() - parent.height());
1069
  }
1070
+ else if(thumbsPositionY > 0) {
1071
  thumbsPositionY = 0;
1072
  }
1073
  else {
1077
  prevX = currX;
1078
  prevY = currY;
1079
 
1080
+ if(parent.width() < child.outerWidth()) {
1081
  child.css('margin-left', thumbsPositionX);
1082
  }
1083
+ if(parent.height() < child.outerHeight()) {
1084
  child.css('margin-top', thumbsPositionY);
1085
  }
1086
  });
1087
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1088
  },
1089
 
1090
+ openLink: function(url, target) {// Open a link.
1091
+ switch(target.toLowerCase()) {
1092
  case '_blank':
1093
  window.open(url);
1094
  break;
1102
  window.location = url;
1103
  }
1104
  },
1105
+ $_GET: function(variable) {
1106
  var url = window.location.href.split('?')[1];
1107
+ if(url) {
1108
  url = url.split('#')[0];
1109
+ var variables = (typeof(url) === 'undefined')? [] : url.split('&'),
1110
  i;
1111
 
1112
+ for(i = 0; i < variables.length; i++) {
1113
+ if(variables[i].indexOf(variable) != -1) {
1114
  return variables[i].split('=')[1];
1115
  }
1116
  }
1118
 
1119
  return false;
1120
  },
1121
+ doHideBuster: function(item) {// Make all parents & current item visible
1122
  var parent = item.parent(),
1123
  items = [];
1124
 
1125
  if (typeof(item.prop('tagName')) !== 'undefined' && item.prop('tagName').toLowerCase() != 'body') {
1126
+ items = this.doHideBuster(parent);
 
1127
 
 
 
1128
  item.addClass('gmShowBuster');
1129
  items.push(item);
1130
  }
1131
 
1132
  return items;
1133
  }