This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Gallery Pastebin - Paste and link to it

Posted by phinze Wed 18th Jun 2008 18:08

Description: ImageAreasCallback.inc
  1. <?php
  2. /*
  3. * Gallery - a web based photo album viewer and editor
  4. * Copyright (C) 2000-2007 Bharat Mediratta
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
  19. */
  20.  
  21. GalleryCoreApi::requireOnce('modules/imageareas/classes/ImageAreasHelper.class');
  22. GalleryCoreApi::requireOnce('modules/imageareas/classes/ImageAreasImage.class');
  23. GalleryCoreApi::requireOnce('modules/imageareas/classes/ImageArea.class');
  24. GalleryCoreApi::requireOnce('lib/JSON/JSON.php');
  25.  
  26. /**
  27. * This view handles Ajax calls.
  28. * @package ImageAreas
  29. * @author  Paul Hinze <paul [dot] t [dot] hinze [at] gmail [dot] com>
  30. * @version $Revision: 1235 $
  31. */
  32. class ImageAreasCallbackView extends GalleryView {
  33.  
  34.     /**
  35.      * @see GalleryView::isImmediate
  36.      */
  37.     function isImmediate() {
  38.         return true;
  39.     }
  40.  
  41.     /**
  42.      * @see GalleryView::isControllerLike
  43.      */
  44.     function isControllerLike() {
  45.         return true;
  46.     }
  47.  
  48.     /**
  49.      * @see GalleryView::renderImmediate
  50.      */
  51.     function renderImmediate($status, $error) {
  52.         global $gallery;
  53.         $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
  54.         $result = array();
  55.         $ret = null;
  56.  
  57.         $action = GalleryUtilities::getRequestVariables('action');
  58.  
  59.         switch ($action) {
  60.         case 'display':
  61.             list($src, $width, $height, $alt, $itemId) =
  62.                 GalleryUtilities::getRequestVariables('src','width','height','alt', 'itemId');
  63.             $img = new ImageAreasImage($src, $width, $height, $alt, $itemId);
  64.             list ($ret, $html) = ImageAreasHelper::getImageAreasUI($img);
  65.             if (!$ret) {
  66.                 echo 'displayHTML##'.$html.'##';
  67.             }
  68.             break;
  69.  
  70.         case 'add':
  71.             list($src, $itemId, $json_data) =
  72.                 GalleryUtilities::getRequestVariables('src','itemId', 'data');
  73.             $data = $json->decode(ImageAreasHelper::xmldecode($json_data));
  74.                             
  75.             $area = new ImageArea($data['areaId'], $itemId, $data['areaTitle'],
  76.                         $data['areaContent'], $data['areaBounds']);
  77.  
  78.             list ($ret, $newId) = ImageAreasHelper::addArea($area);
  79.             $result['newId'] = $newId;
  80.             break;
  81.             
  82.         case 'modify':
  83.             list($src, $itemId, $json_data) =
  84.                 GalleryUtilities::getRequestVariables('src','itemId', 'data');
  85.             $data = $json->decode(ImageAreasHelper::xmldecode($json_data));
  86.                             
  87.             $area = new ImageArea($data['areaId'], $itemId, $data['areaTitle'],
  88.                         $data['areaContent'], $data['areaBounds']);
  89.  
  90.             $ret = ImageAreasHelper::updateArea($area);
  91.             break;
  92.             
  93.         case 'delete':
  94.             list($src, $itemId, $json_data) =
  95.                 GalleryUtilities::getRequestVariables('src','itemId', 'data');
  96.             $data = $json->decode(ImageAreasHelper::xmldecode($json_data));
  97.                             
  98.             $ret = ImageAreasHelper::deleteArea($data['areaId']);
  99.             break;
  100.             
  101.         default:
  102.             $ret = GalleryCoreApi::error(ERROR_BAD_PARAMETER);
  103.         }
  104.  
  105.         if ($ret) {
  106.             $result['status'] = 'error';
  107.             $result['ret']    = $ret->getAsText();
  108.         } else {
  109.             $result['status'] = 'success';
  110.         }
  111.  
  112.         print $json->encode($result);
  113.         return null;
  114.     }
  115.  
  116. }
  117. ?>
  118.  

PermaLink to this entry http://tools.gallery2.org/pastebin/1999 Download 1999.txt
Submit a correction or amendment below. (click here to make a fresh posting)

Your Name
Syntax:
For (optional)
Leave permalink as note for user. Remember my name in a cookie

Select channel for announcement:
#gallery#gallery-support

Code: To ensure legibility, keep your code lines under 80 characters long.

You can highlight lines: start with "@#" and end with "!#"

Description: You can leave a small description for your code. (Errors, etc)

Please note that your script will be available publicly.
Page generated in 0.280 seconds.