Advertisement
Guest User

tidypics diff

a guest
Aug 26th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.61 KB | None | 0 0
  1. diff --git i/languages/de.php w/languages/de.php
  2. index 11b05de..d4dad4d 100644
  3. --- i/languages/de.php
  4. +++ w/languages/de.php
  5. @@ -209,7 +209,7 @@ return array(
  6. 'tidypics:uploader:choose' => "Wähle die Bilder aus",
  7. 'tidypics:uploader:upload' => "Lade die Bilder hoch",
  8. 'tidypics:uploader:describe' => "Gebe Beschreibungen für die Bilder ein",
  9. - 'tidypics:uploader:instructs' => 'Das Hochladen von Bilder erfolgt in drei einfachen Schritten: auf dieser Seite kannst Du zuerst die Bilder zum Hochladen auswählen und im Anschluss diese Bilder hochladen. Nachdem das Hochladen abgeschlossen ist, wirst Du automatisch zu einer neuen Seite weitergeleitet, wo Du im letzen Schritt dann Titel und Beschreibungen für diese Bilder eingeben kannst.<br><br> Du kannst bis zu 10 Bilder auf einmal hochladen (maximale Dateigröße %s MB pro Bild).',
  10. + 'tidypics:uploader:instructs' => 'Das Hochladen von Bilder erfolgt in drei einfachen Schritten: auf dieser Seite kannst Du zuerst die Bilder zum Hochladen auswählen und im Anschluss diese Bilder hochladen. Nachdem das Hochladen abgeschlossen ist, wirst Du automatisch zu einer neuen Seite weitergeleitet, wo Du im letzen Schritt dann Titel und Beschreibungen für diese Bilder eingeben kannst.<br><br> Du kannst bis zu %s Bilder auf einmal hochladen (maximale Dateigröße %s MB pro Bild).',
  11. 'tidypics:uploader:basic' => 'Du kannst bis zu 10 Bilder auf einmal hochladen (maximale Dateigröße %s MB pro Bild). Nachdem das Hochladen der ausgewählten Bilder abgeschlossen ist, wirst Du automatisch zu einer neuen Seite weitergeleitet, wo Du dann Titel und Beschreibungen für diese Bilder eingeben kannst.',
  12. 'tidypics:sort:instruct' => 'Sortiere die Bilder im Album durch Drag-and-Drop um. Dann speichere Deine Änderungen.',
  13. 'tidypics:sort:no_images' => 'Es wurden keine Bilder gefunden, die umsortiert werden könnten. Lade Bilder hoch, indem Du dem obigen Link folgst.',
  14. @@ -360,4 +360,4 @@ Schau Dir das Bilderalbum an und schreibe einen Kommentar:
  15. 'image:error' => 'Das Bild konnte nicht gespeichert werden.',
  16.  
  17. 'tidypics:upgrade:failed' => "Das Upgrade des Tidypics-Plugins ist gescheitert"
  18. -);
  19. \ No newline at end of file
  20. +);
  21. diff --git i/languages/en.php w/languages/en.php
  22. index 2173789..26fbfbe 100644
  23. --- i/languages/en.php
  24. +++ w/languages/en.php
  25. @@ -144,6 +144,9 @@ return array(
  26. 'tidypics:resize_thumbnails:finished' => "The re-recreation of thumbnails of all %s photos has been finished successfully.",
  27. 'tidypics:resize_thumbnails:finished_with_errors' => "The re-recreation of thumbnails has been finished. There were some errors though: %s photos with invalid data (no re-creation of thumbnails done here) and on %s photos occured an error during creation of thumbnails.",
  28.  
  29. + 'tidypics:settings:maxuploads' => 'Set max uploads allowed via the ajax Plupload',
  30. + 'tidypics:settings:default_menu' => 'Set menu to all photos or all albums',
  31. +
  32. // Server analysis
  33. 'tidypics:server_info' => 'Server Information',
  34. 'tidypics:server_info:gd_desc' => 'Elgg requires the GD extension to be loaded',
  35. @@ -209,7 +212,7 @@ return array(
  36. 'tidypics:uploader:choose' => "Choose photos",
  37. 'tidypics:uploader:upload' => "Upload photos",
  38. 'tidypics:uploader:describe' => "Describe photos",
  39. - 'tidypics:uploader:instructs' => 'There are three easy steps for adding photos to your album using this uploader: on this page you need to choose the photos to be uploaded first and then upload them in a second step. After the upload has finished you will be automatically redirected to a new page where you can enter titles and descriptions for the uploaded photos as the last step.<br><br> You can upload up to 10 photos at a time (%s MB maximum per photo).',
  40. + 'tidypics:uploader:instructs' => 'There are three easy steps for adding photos to your album using this uploader: on this page you need to choose the photos to be uploaded first and then upload them in a second step. After the upload has finished you will be automatically redirected to a new page where you can enter titles and descriptions for the uploaded photos as the last step.<br><br> You can upload up to %s photos at a time (%s MB maximum per photo).',
  41. 'tidypics:uploader:basic' => 'You can upload up to 10 photos at a time (%s MB maximum per photo). After the upload of the selected photos is finished you will be redirected to a new page where you can enter titles and descriptions for the uploaded photos.',
  42. 'tidypics:sort:instruct' => 'Sort the album photos by dragging and dropping the photos. Then click the save button.',
  43. 'tidypics:sort:no_images' => 'No photos found to sort. Upload photos using the link above.',
  44. @@ -360,4 +363,4 @@ View and comment on the album:
  45. 'image:error' => 'Could not save photo.',
  46.  
  47. 'tidypics:upgrade:failed' => "The upgrade of Tidypics failed"
  48. -);
  49. \ No newline at end of file
  50. +);
  51. diff --git i/languages/es.php w/languages/es.php
  52. index 685b11f..f3188b7 100644
  53. --- i/languages/es.php
  54. +++ w/languages/es.php
  55. @@ -198,7 +198,7 @@ return array(
  56. 'tidypics:uploader:choose' => "Elija las fotos",
  57. 'tidypics:uploader:upload' => "Suba las fotos",
  58. 'tidypics:uploader:describe' => "Describa las fotos",
  59. - 'tidypics:uploader:instructs' => 'Hay tres sencillos pasos para agregar fotos a su álbum con este cargador: En esta página es necesario elegir las fotos que se cargan primero y luego subirlas en un segundo paso. Después que la carga haya finalizado, será redirigido a una nueva página donde podrá introducir los títulos y descripciones de las fotos cargadas en el último paso.<br><br> Puedes subir hasta 10 fotos a la vez (%s MB máximo por foto).',
  60. + 'tidypics:uploader:instructs' => 'Hay tres sencillos pasos para agregar fotos a su álbum con este cargador: En esta página es necesario elegir las fotos que se cargan primero y luego subirlas en un segundo paso. Después que la carga haya finalizado, será redirigido a una nueva página donde podrá introducir los títulos y descripciones de las fotos cargadas en el último paso.<br><br> Puedes subir hasta %s fotos a la vez (%s MB máximo por foto).',
  61. 'tidypics:uploader:basic' => 'Puedes subir hasta 10 fotos a la vez (%s MB máximo por foto). Una vez finalizada la carga de las fotografías seleccionadas se le redirige a una nueva página donde podrá introducir los títulos y descripciones de las fotos subidas.',
  62. 'tidypics:sort:instruct' => 'Para clasificar los fotos del álbum arrastr y suelte las fotos. Luego haga clic en el botón Guardar.',
  63. 'tidypics:sort:no_images' => 'No se encontraron fotos para ordenar. Sube fotos usando el enlace de arriba.',
  64. @@ -349,4 +349,4 @@ Ver y hacer comentarios sobre el álbum:
  65. 'image:error' => 'No se pudo guardar la foto.',
  66.  
  67. 'tidypics:upgrade:failed' => "La actualización de Tidypics fracasó"
  68. -);
  69. \ No newline at end of file
  70. +);
  71. diff --git i/languages/fr.php w/languages/fr.php
  72. index c18a9ed..5c69204 100755
  73. --- i/languages/fr.php
  74. +++ w/languages/fr.php
  75. @@ -61,7 +61,7 @@ Vous pouvez rencontrer des problèmes avec la création de miniatures si votre b
  76. 'tidypics:uploader:filedesc' => 'Fichiers image (jpeg, png, gif)',
  77. 'tidypics:uploader:instructs' => 'Il y a 3 étapes simples pour ajouter des photos à votre album en utilisant cet outil d\'envoi : les choisir, les envoyer, et les décrire.
  78. Il y a une limite de %s Mo maximum par photo. Si vous n\'utilisez pas Flash, un <a href="%s">autre outil d\'envoi simple</a> est également disponible.',
  79. - 'tidypics:uploader:basic' => 'Vous pouvez charger jusqu\'à 10 photos à la fois (%s Mo maximum par photo)',
  80. + 'tidypics:uploader:basic' => 'Vous pouvez charger jusqu\'à %s photos à la fois (%s Mo maximum par photo)',
  81. 'tidypics:sort:instruct' => 'Triez l\'album photo en cliquant et en déplaçant les images. Puis cliquez sur le bouton Enregistrer.',
  82. 'tidypics:sort:no_images' => 'Aucune image à trier. Chargez d\'abord des images en cliquant sur le lien ci-dessus.',
  83. 'album:num' => 'Photos de %s',
  84. @@ -226,4 +226,4 @@ La photo peut être consultée ici: %s',
  85. 'album:deletefailed' => 'Votre album ne peut pas être supprimé pour le moment',
  86. 'album:blank' => 'Donnez un titre et une description à cet album',
  87. 'tidypics:upgrade:failed' => 'Mise à jour de Tydipics infructueuse',
  88. -);
  89. \ No newline at end of file
  90. +);
  91. diff --git i/lib/exif.php w/lib/exif.php
  92. index d1c0e54..0c2cc32 100644
  93. --- i/lib/exif.php
  94. +++ w/lib/exif.php
  95. @@ -23,16 +23,31 @@ function td_get_exif($image) {
  96. }
  97.  
  98. $filename = $image->getFilenameOnFilestore();
  99. - $exif = exif_read_data($filename, 'IFD0,EXIF', true);
  100. + $exif = exif_read_data($filename, "ANY_TAG", true);
  101. if (is_array($exif)) {
  102. - $data = array_merge($exif['IFD0'], $exif['EXIF']);
  103. - foreach ($data as $key => $value) {
  104. - if (is_string($value)) {
  105. - // there are sometimes unicode characters that cause problems with serialize
  106. - $data[$key] = preg_replace( '/[^[:print:]]/', '', $value);
  107. - }
  108. + // GPS data
  109. + $gps_exif = array_intersect_key($exif['GPS'], array_flip(array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude')));
  110. +
  111. + $data = array_merge($exif['IFD0'], $exif['EXIF']);
  112. + foreach ($data as $key => $value) {
  113. + if (is_string($value)) {
  114. + // there are sometimes unicode characters that cause problems with serialize
  115. + $data[$key] = preg_replace( '/[^[:print:]]/', '', $value);
  116. + }
  117. + }
  118. +
  119. + if (count($gps_exif) == 4)
  120. + {
  121. + if (
  122. + is_array($gps_exif['GPSLatitude']) and in_array($gps_exif['GPSLatitudeRef'], array('S', 'N')) and
  123. + is_array($gps_exif['GPSLongitude']) and in_array($gps_exif['GPSLongitudeRef'], array('W', 'E'))
  124. + )
  125. + {
  126. + $data['latitude'] = parse_exif_gps_data($gps_exif['GPSLatitude'], $gps_exif['GPSLatitudeRef']);
  127. + $data['longitude'] = parse_exif_gps_data($gps_exif['GPSLongitude'], $gps_exif['GPSLongitudeRef']);
  128. }
  129. - $image->tp_exif = serialize($data);
  130. + }
  131. + $image->tp_exif = serialize($data);
  132. }
  133. }
  134.  
  135. @@ -106,5 +121,40 @@ function tp_exif_formatted($image) {
  136. }
  137. $exif_data['Captured'] = $captured;
  138.  
  139. + //if ($exif['latitude'] && $exif['longitude']) {
  140. + // $exif_data['latitude'] = $exif['latitude'];
  141. + // $exif_data['longitude'] = $exif['longitude'];
  142. + //}
  143. +
  144. return $exif_data;
  145. }
  146. +
  147. +
  148. +/**
  149. + * Converts EXIF GPS format to a float value.
  150. + * @since 2.6
  151. + *
  152. + * @param string[] $raw eg:
  153. + * - 41/1
  154. + * - 54/1
  155. + * - 9843/500
  156. + * @param string $ref 'S', 'N', 'E', 'W'. eg: 'N'
  157. + * @return float eg: 41.905468
  158. + */
  159. +function parse_exif_gps_data($raw, $ref)
  160. +{
  161. + foreach ($raw as &$i)
  162. + {
  163. + $i = explode('/', $i);
  164. + $i = $i[1]==0 ? 0 : $i[0]/$i[1];
  165. + }
  166. + unset($i);
  167. +
  168. + $v = $raw[0] + $raw[1]/60 + $raw[2]/3600;
  169. +
  170. + $ref = strtoupper($ref);
  171. + if ($ref == 'S' or $ref == 'W') $v= -$v;
  172. +
  173. + return $v;
  174. +}
  175. +
  176. diff --git i/start.php w/start.php
  177. index 4634dc8..c092daa 100644
  178. --- i/start.php
  179. +++ w/start.php
  180. @@ -23,10 +23,14 @@ function tidypics_init() {
  181. // Register an ajax view that allows selection of album to upload images to
  182. elgg_register_ajax_view('photos/selectalbum');
  183.  
  184. + $menu_item = elgg_get_plugin_setting('default_menu', 'tidypics');
  185. + if (!$menu_item) {
  186. + $menu_item = "photos/siteimagesall";
  187. + }
  188. // Set up site menu
  189. elgg_register_menu_item('site', array(
  190. 'name' => 'photos',
  191. - 'href' => 'photos/siteimagesall',
  192. + 'href' => "$menu_item",
  193. 'text' => elgg_echo('photos'),
  194. ));
  195.  
  196. diff --git i/views/default/forms/photos/admin/settings/main.php w/views/default/forms/photos/admin/settings/main.php
  197. index 410c4fc..de91b3c 100644
  198. --- i/views/default/forms/photos/admin/settings/main.php
  199. +++ w/views/default/forms/photos/admin/settings/main.php
  200. @@ -47,3 +47,24 @@ echo elgg_view('input/text', array(
  201. 'value' => $quota,
  202. ));
  203. echo '</div>';
  204. +
  205. +$max_uploads = intval($plugin->max_uploads);
  206. +if (!$max_uploads) {
  207. + $max_uploads = 10;
  208. +}
  209. +echo '<div>' . elgg_echo('tidypics:settings:maxuploads');
  210. +echo elgg_view('input/text', array(
  211. + 'name' => 'params[max_uploads]',
  212. + 'value' => $max_uploads,
  213. +));
  214. +echo '</div>';
  215. +
  216. +echo'<div>';
  217. +echo elgg_echo('tidypics:settings:default_menu') . ': ';
  218. +echo elgg_view('input/select', array(
  219. + 'name' => 'params[default_menu]',
  220. + 'options' => array ("photos/siteimagesall", "photos/all"),
  221. + 'value' => $plugin->default_menu,
  222. +));
  223. +echo '</div>';
  224. +
  225. diff --git i/views/default/forms/photos/ajax_upload.php w/views/default/forms/photos/ajax_upload.php
  226. index 44b43d4..e710eb7 100644
  227. --- i/views/default/forms/photos/ajax_upload.php
  228. +++ w/views/default/forms/photos/ajax_upload.php
  229. @@ -19,15 +19,20 @@ if (!$maxfilesize) {
  230.  
  231. $maxfilesize_int = (int) $maxfilesize;
  232.  
  233. +$max_uploads = intval(elgg_get_plugin_setting('max_uploads', 'tidypics'));
  234. +if (!$max_uploads) {
  235. + $max_uploads = 10;
  236. +}
  237. +
  238. ?>
  239.  
  240. <p>
  241. <?php
  242. - echo elgg_echo('tidypics:uploader:instructs', array($maxfilesize));
  243. + echo elgg_echo('tidypics:uploader:instructs', array($max_uploads, $maxfilesize));
  244. ?>
  245. </p>
  246.  
  247. -<div id="uploader" data-maxfilesize="<?php echo $maxfilesize_int; ?>">
  248. +<div id="uploader" data-maxfilesize="<?php echo $maxfilesize_int; ?>" data-max_uploads="<?php echo $max_uploads; ?>">
  249. <input type="hidden" name="album_guid" value="<?php echo $album->getGUID(); ?>" />
  250. <input type="hidden" name="batch" value="<?php echo $batch; ?>" />
  251. <input type="hidden" name="tidypics_token" value="<?php echo $tidypics_token; ?>" />
  252. diff --git i/views/default/js/tidypics/uploading.js w/views/default/js/tidypics/uploading.js
  253. index c15903a..d61a439 100644
  254. --- i/views/default/js/tidypics/uploading.js
  255. +++ w/views/default/js/tidypics/uploading.js
  256. @@ -12,8 +12,9 @@ define(function(require) {
  257. data[name] = value;
  258. }
  259. });
  260. -
  261. +
  262. var maxfilesize = $("#uploader").data('maxfilesize');
  263. + var max_uploads = $("#uploader").data('max_uploads');
  264.  
  265. $("#uploader").plupload({
  266. // General settings
  267. @@ -53,21 +54,19 @@ define(function(require) {
  268. },
  269.  
  270. FilesAdded: function(up, files) {
  271. - var maxfiles = 10;
  272. - if(up.files.length > maxfiles ) {
  273. - alert(elgg.echo('tidypics:exceedmax_number', [maxfiles]));
  274. + if(up.files.length > max_uploads ) {
  275. + alert(elgg.echo('tidypics:exceedmax_number', [max_uploads]));
  276. }
  277. - if(up.files.length > maxfiles ) {
  278. - up.splice(maxfiles);
  279. + if(up.files.length > max_uploads ) {
  280. + up.splice(max_uploads);
  281. }
  282. - if (up.files.length >= maxfiles) {
  283. + if (up.files.length >= max_uploads) {
  284. up.disableBrowse(true);
  285. }
  286. },
  287.  
  288. FilesRemoved: function(up, files) {
  289. - var maxfiles = 10;
  290. - if (up.files.length < maxfiles) {
  291. + if (up.files.length < max_uploads) {
  292. up.disableBrowse(false);
  293. }
  294. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement