PageRenderTime 24ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/site/cms/modules/media/Galleries.hx

http://poko.googlecode.com/
Haxe | 77 lines | 40 code | 11 blank | 26 comment | 11 complexity | 9c26b47d1872a1b7e8929ce049b0f940 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1
  1. /*
  2. * Copyright (c) 2008, TouchMyPixel & contributors
  3. * Original author : Tony Polinelli <tonyp@touchmypixel.com>
  4. * Contributers: Tarwin Stroh-Spijer
  5. * All rights reserved.
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * - Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * - Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE TOUCH MY PIXEL & CONTRIBUTERS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. * ARE DISCLAIMED. IN NO EVENT SHALL THE TOUCH MY PIXEL & CONTRIBUTORS
  19. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  25. * THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. package site.cms.modules.media;
  28. import php.FileSystem;
  29. import site.cms.modules.media.Index;
  30. class Galleries extends MediaBase
  31. {
  32. public var galleries:List<Dynamic>;
  33. override public function init()
  34. {
  35. super.init();
  36. if (app.params.get("action")) process();
  37. }
  38. override public function main()
  39. {
  40. galleries = new List();
  41. var dir = FileSystem.readDirectory(imageRoot);
  42. for (d in dir)
  43. {
  44. if (FileSystem.isDirectory(imageRoot + "/" +d) && d != "." && d != ".." && d != ".svn")
  45. {
  46. galleries.add( { name:d } );
  47. }
  48. }
  49. setupLeftNav();
  50. }
  51. private function process():Void
  52. {
  53. switch(app.params.get("action"))
  54. {
  55. case "add":
  56. var dir = imageRoot + "/" + app.params.get("newGallery");
  57. if (!FileSystem.exists(dir))
  58. {
  59. FileSystem.createDirectory(dir);
  60. messages.addMessage("Gallery Added");
  61. } else {
  62. messages.addError("A Gallery of this name already exists");
  63. }
  64. }
  65. }
  66. }