A_Upload_Images_Form

Class A_Upload_Images_Form.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/nextgen_addgallery_page/package.module.nextgen_addgallery_page.php  
  1. class A_Upload_Images_Form extends Mixin 
  2. function get_title() 
  3. return __("Upload Images", 'nggallery'); 
  4. function get_i18n_strings() 
  5. return array('no_image_uploaded' => __('No images were uploaded successfully.', 'nggallery'), 'one_image_uploaded' => __('1 image was uploaded successfully.', 'nggallery'), 'x_images_uploaded' => __('{count} images were uploaded successfully.', 'nggallery'), 'image_errors' => __('The following errors occured:', 'nggallery'), 'manage_gallery' => __('Manage gallery {name}', 'nggallery')); 
  6. /** 
  7. * Plupload stores its i18n JS *mostly* as "en.js" or "ar.js" - but some as zh_CN.js so we must check both if the 
  8. * first does not match. 
  9. * @return bool|string 
  10. */ 
  11. function _find_plupload_i18n() 
  12. $fs = C_Fs::get_instance(); 
  13. $router = C_Router::get_instance(); 
  14. $locale = get_locale(); 
  15. $dir = $fs->find_static_abspath('photocrati-nextgen_addgallery_page#plupload-2.1.1/i18n') . DIRECTORY_SEPARATOR; 
  16. $tmp = explode('_', $locale, 2); 
  17. $retval = FALSE; 
  18. if (file_exists($dir . $tmp[0] . '.js')) { 
  19. $retval = $tmp[0]; 
  20. } else { 
  21. if (file_exists($dir . $locale . '.js')) { 
  22. $retval = $locale; 
  23. if ($retval) { 
  24. $retval = $router->get_static_url('photocrati-nextgen_addgallery_page#plupload-2.1.1/i18n/' . $retval . '.js'); 
  25. return $retval; 
  26. function enqueue_static_resources() 
  27. wp_enqueue_style('ngg.plupload.queue'); 
  28. wp_enqueue_script('browserplus'); 
  29. wp_enqueue_script('ngg.plupload.queue'); 
  30. wp_localize_script('ngg.plupload.queue', 'NggUploadImages_i18n', $this->object->get_i18n_strings()); 
  31. $i18n = $this->_find_plupload_i18n(); 
  32. if (!empty($i18n)) { 
  33. wp_enqueue_script('ngg.plupload.i18n', $i18n, array('ngg.plupload.full'), NGG_SCRIPT_VERSION); 
  34. function render() 
  35. return $this->object->render_partial('photocrati-nextgen_addgallery_page#upload_images', array('plupload_options' => json_encode($this->object->get_plupload_options()), 'galleries' => $this->object->get_galleries(), 'sec_token' => C_WordPress_Security_Manager::get_instance()->get_request_token('nextgen_upload_image')), TRUE); 
  36. function get_plupload_options() 
  37. $retval = array(); 
  38. $retval['runtimes'] = 'gears, browserplus, html5, flash, silverlight, html4'; 
  39. $retval['max_file_size'] = strval(round((int) wp_max_upload_size() / 1024)) . 'kb'; 
  40. $retval['filters'] = $this->object->get_plupload_filters(); 
  41. $retval['flash_swf_url'] = includes_url('js/plupload/plupload.flash.swf'); 
  42. $retval['silverlight_xap_url'] = includes_url('js/plupload/plupload.silverlight.xap'); 
  43. $retval['debug'] = TRUE; 
  44. $retval['prevent_duplicates'] = TRUE; 
  45. return $retval; 
  46. function get_plupload_filters() 
  47. $retval = new stdClass(); 
  48. $retval->mime_types = array(); 
  49. $imgs = new stdClass(); 
  50. $imgs->title = "Image files"; 
  51. $imgs->extensions = "jpg, jpeg, gif, png, JPG, JPEG, GIF, PNG"; 
  52. $retval->mime_types[] = $imgs; 
  53. $settings = C_NextGen_Settings::get_instance(); 
  54. if (!is_multisite() || is_multisite() && $settings->get('wpmuZipUpload')) { 
  55. $zips = new stdClass(); 
  56. $zips->title = "Zip files"; 
  57. $zips->extensions = "zip, ZIP"; 
  58. $retval->mime_types[] = $zips; 
  59. $retval->xss_protection = TRUE; 
  60. return $retval; 
  61. function get_galleries() 
  62. $security = $this->get_registry()->get_utility('I_Security_Manager'); 
  63. $sec_actor = $security->get_current_actor(); 
  64. $galleries = array(); 
  65. if ($sec_actor->is_allowed('nextgen_edit_gallery')) { 
  66. $gallery_mapper = C_Gallery_Mapper::get_instance(); 
  67. $galleries = $gallery_mapper->find_all(); 
  68. if (!$sec_actor->is_allowed('nextgen_edit_gallery_unowned')) { 
  69. $galleries_all = $galleries; 
  70. $galleries = array(); 
  71. foreach ($galleries_all as $gallery) { 
  72. if ($sec_actor->is_user() && $sec_actor->get_entity_id() == (int) $gallery->author) { 
  73. $galleries[] = $gallery; 
  74. return $galleries;