1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Basic_Saveimage extends IMP_Basic_Base
24: {
25: 26:
27: protected function _init()
28: {
29: global $injector, $notification, $page_output, $registry;
30:
31: if (!$registry->hasMethod('images/selectGalleries') ||
32: !$registry->hasMethod('images/saveImage')) {
33: $e = new IMP_Exception('Image saving is not available.');
34: $e->logged = true;
35: throw $e;
36: }
37:
38:
39: switch ($this->vars->actionID) {
40: case 'save_image':
41: $contents = $injector->getInstance('IMP_Factory_Contents')->create($this->indices);
42: $mime_part = $contents->getMIMEPart($this->vars->id);
43: $image_data = array(
44: 'data' => $mime_part->getContents(),
45: 'description' => $mime_part->getDescription(true),
46: 'filename' => $mime_part->getName(true),
47: 'type' => $mime_part->getType()
48: );
49: try {
50: $registry->images->saveImage($this->vars->gallery, $image_data);
51: } catch (Horde_Exception $e) {
52: $notification->push($e);
53: break;
54: }
55: echo Horde::wrapInlineScript(array('window.close();'));
56: exit;
57: }
58:
59:
60: $view = new Horde_View(array(
61: 'templatePath' => IMP_TEMPLATES . '/saveimage'
62: ));
63: $view->addHelper('Horde_Core_View_Helper_Image');
64: $view->addHelper('Text');
65:
66: $view->action = self::url();
67: $view->gallerylist = $registry->images->selectGalleries(array(
68: 'perm' => Horde_Perms::EDIT
69: ));
70: $view->id = $this->vars->id;
71: $view->muid = strval($this->indices);
72:
73: $page_output->topbar = $page_output->sidebar = false;
74:
75: $page_output->addInlineScript(array(
76: '$$("INPUT.horde-cancel").first().observe("click", function() { window.close(); })'
77: ), true);
78:
79: $this->title = _("Save Image");
80: $this->output = $view->render('saveimage');
81: }
82:
83: 84:
85: public static function url(array $opts = array())
86: {
87: return Horde::url('basic.php')->add('page', 'saveimage');
88: }
89:
90: }
91: