1: <?php
2: /**
3: * LICENSE (BSD)
4: *
5: * Copyright (c) 2013, Gerd Christian Kunze
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions are
10: * met:
11: *
12: * * Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: *
15: * * Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: *
19: * * Neither the name of Gerd Christian Kunze nor the names of the
20: * contributors may be used to endorse or promote products derived from
21: * this software without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34: *
35: * Image
36: * 13.02.2013 13:39
37: */
38: namespace MOC\Module\Office;
39: use MOC\Api;
40: use MOC\Generic\Device\Module;
41: /**
42: *
43: */
44: class Image implements Module{
45:
46: /** @var Image $Singleton */
47: private static $Singleton = null;
48:
49: /**
50: * Get Singleton/Instance
51: *
52: * @static
53: * @return Image
54: */
55: public static function InterfaceInstance() {
56: if( self::$Singleton === null ) {
57: self::$Singleton = new Image();
58: } return self::$Singleton;
59: }
60:
61: /**
62: * Get Changelog
63: *
64: * @static
65: * @return \MOC\Core\Changelog
66: */
67: public static function InterfaceChangelog() {
68: return Api::Core()->Changelog();
69: }
70:
71: /**
72: * Get Dependencies
73: *
74: * @static
75: * @return \MOC\Core\Depending
76: */
77: public static function InterfaceDepending() {
78: return Api::Core()->Depending();
79: }
80:
81: /**
82: * @return Image\Open
83: */
84: public function Open() {
85: return Image\Open::InterfaceInstance();
86: }
87:
88: /**
89: * @return Image\Close
90: */
91: public function Close() {
92: return Image\Close::InterfaceInstance();
93: }
94:
95: /** @var resource[] $Queue */
96: private $Queue = array();
97: /** @var resource $Current */
98: private $Current = null;
99:
100: /**
101: * @return Image\Resize
102: */
103: public function Resize() {
104: return Image\Resize::InterfaceInstance();
105: }
106:
107: /**
108: * @return Image\Filter
109: */
110: public function Filter() {
111: return Image\Filter::InterfaceInstance();
112: }
113:
114: /**
115: * @return Image\Font
116: */
117: public function Font() {
118: return Image\Font::InterfaceInstance();
119: }
120:
121: /**
122: * @param resource $Resource
123: *
124: * @return Image
125: */
126: public function _openResource( $Resource ) {
127: $this->Current = $Resource;
128: array_push( $this->Queue, $this->Current );
129: return $this;
130: }
131:
132: /**
133: * @param $Index
134: *
135: * @return Image
136: */
137: public function _selectResource( $Index ) {
138: $this->Current = $this->Queue[$Index];
139: return $this;
140: }
141:
142: /**
143: * @return resource
144: */
145: public function _getResource() {
146: return $this->Current;
147: }
148:
149: /**
150: * @return Image
151: */
152: public function _closeResource() {
153: $this->Current = null;
154: return $this;
155: }
156: }
157: