1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: $plugin_description = gettext('Overlay icons over thumbnails to indicate image status.');
25: $plugin_author = "Stephen Billard (sbillard)";
26:
27: $option_interface = 'flag_thumbnail';
28:
29: zp_register_filter('standard_image_thumb_html', 'flag_thumbnail::std_image_thumbs');
30: zp_register_filter('standard_album_thumb_html', 'flag_thumbnail::std_album_thumbs', 99);
31: zp_register_filter('custom_album_thumb_html', 'flag_thumbnail::custom_album_thumbs', 99);
32: zp_register_filter('custom_image_html', 'flag_thumbnail::custom_images', 99);
33:
34: 35: 36: 37:
38: class flag_thumbnail {
39:
40: function __construct() {
41: setOptionDefault('flag_thumbnail_date', 'date');
42: setOptionDefault('flag_thumbnail_range', '3');
43: setOptionDefault('flag_thumbnail_new_text', 'NEW');
44: setOptionDefault('flag_thumbnail_unpublished_text', 'unpub');
45: setOptionDefault('flag_thumbnail_locked_text', 'locked');
46: setOptionDefault('flag_thumbnail_geodata_text', 'GPS');
47: setOptionDefault('flag_thumbnail_use_text', '');
48: setOptionDefault('flag_thumbnail_flag_new', 1);
49: setOptionDefault('flag_thumbnail_flag_locked', 1);
50: setOptionDefault('flag_thumbnail_flag_unpublished', 1);
51: setOptionDefault('flag_thumbnail_flag_geodata', 1);
52: setOptionDefault('flag_thumbnail_new_icon', 'new.png');
53: setOptionDefault('flag_thumbnail_unpublished_icon', 'action.png');
54: setOptionDefault('flag_thumbnail_locked_icon', 'lock.png');
55: setOptionDefault('flag_thumbnail_geodata_icon', 'GPS.png');
56: }
57:
58: function getOptionsSupported() {
59: $buttons = array();
60: $icons = getPluginFiles('*.png', 'flag_thumbnail');
61: foreach ($icons as $icon) {
62: $icon = str_replace(SERVERPATH, WEBPATH, $icon);
63: $buttons[' <img src="' . $icon . '" />'] = basename($icon);
64: }
65: return array('» ' . gettext('Criteria') => array('key' => 'flag_thumbnail_date', 'type' => OPTION_TYPE_SELECTOR,
66: 'order' => 3.6,
67: 'selections' => array(gettext('date') => "date", gettext('mtime') => "mtime"),
68: 'desc' => gettext("Select the basis for considering if an image is new.")),
69: '» ' . gettext('Icon') . chr(0) . '3' => array('key' => 'flag_thumbnail_new_icon', 'type' => OPTION_TYPE_RADIO,
70: 'order' => 3.1,
71: 'buttons' => $buttons, 'behind' => true,
72: 'desc' => gettext('Select the icon that will show for “new” images.')),
73: '» ' . gettext('Icon') . chr(0) . '2' => array('key' => 'flag_thumbnail_unpublished_icon', 'type' => OPTION_TYPE_RADIO,
74: 'order' => 2.1,
75: 'buttons' => $buttons, 'behind' => true,
76: 'desc' => gettext('Select the icon that will show for “un-published” images.')),
77: '» ' . gettext('Icon') . chr(0) . '4' => array('key' => 'flag_thumbnail_locked_icon', 'type' => OPTION_TYPE_RADIO,
78: 'order' => 4.1,
79: 'buttons' => $buttons, 'behind' => true,
80: 'desc' => gettext('Select the icon that will show for “Protected” images.')),
81: '» ' . gettext('Icon') . chr(0) . '5' => array('key' => 'flag_thumbnail_geodata_icon', 'type' => OPTION_TYPE_RADIO,
82: 'order' => 5.1,
83: 'buttons' => $buttons, 'behind' => true,
84: 'desc' => gettext('Select the icon that will show for images tagged with geodata.')),
85: gettext('Un-published') => array('key' => 'flag_thumbnail_flag_unpublished', 'type' => OPTION_TYPE_CHECKBOX,
86: 'order' => 2,
87: 'desc' => gettext('Thumbnails for images which are not <em>published</em> will be marked.')),
88: gettext('Protected') => array('key' => 'flag_thumbnail_flag_locked', 'type' => OPTION_TYPE_CHECKBOX,
89: 'order' => 4,
90: 'desc' => gettext('Thumbnails for images which are password protected or in password protected albums will be marked.')),
91: gettext('New') => array('key' => 'flag_thumbnail_flag_new', 'type' => OPTION_TYPE_CHECKBOX,
92: 'order' => 3,
93: 'desc' => gettext('Thumbnails for images which have recently been added to the gallery will be marked.')),
94: gettext('Geotagged') => array('key' => 'flag_thumbnail_flag_geodata', 'type' => OPTION_TYPE_CHECKBOX,
95: 'order' => 5,
96: 'desc' => gettext('Thumbnails for images which are geodata tagged will be marked.')),
97: '» ' . gettext('Text') . chr(0) . '5' => array('key' => 'flag_thumbnail_geodata_text', 'type' => OPTION_TYPE_TEXTBOX,
98: 'order' => 5.5,
99: 'desc' => gettext("Text flag for <em>geodata tagged</em> images.")),
100: 5 => array('type' => OPTION_TYPE_NOTE,
101: 'order' => 5.9,
102: 'desc' => '<hr />'),
103: '» ' . gettext('Aging') => array('key' => 'flag_thumbnail_range', 'type' => OPTION_TYPE_TEXTBOX,
104: 'order' => 3.7,
105: 'desc' => gettext("The range in days until images are no longer flagged as new.")),
106: '» ' . gettext('Text') . chr(0) . '3' => array('key' => 'flag_thumbnail_new_text', 'type' => OPTION_TYPE_TEXTBOX,
107: 'order' => 3.5,
108: 'desc' => gettext("Text flag for <em>new</em> images.")),
109: 3 => array('type' => OPTION_TYPE_NOTE,
110: 'order' => 3.9,
111: 'desc' => '<hr />'),
112: '» ' . gettext('Text') . chr(0) . '2' => array('key' => 'flag_thumbnail_unpublished_text', 'type' => OPTION_TYPE_TEXTBOX,
113: 'order' => 2.5,
114: 'desc' => gettext("Text flag for <em>un-published</em> images.")),
115: 2 => array('type' => OPTION_TYPE_NOTE,
116: 'order' => 2.9,
117: 'desc' => '<hr />'),
118: '» ' . gettext('Text') . chr(0) . '4' => array('key' => 'flag_thumbnail_locked_text', 'type' => OPTION_TYPE_TEXTBOX,
119: 'order' => 4.5,
120: 'desc' => gettext("Text flag for <em>protected</em> images.")),
121: 4 => array('type' => OPTION_TYPE_NOTE,
122: 'order' => 4.9,
123: 'desc' => '<hr />'),
124: gettext('Use text') => array('key' => 'flag_thumbnail_use_text', 'type' => OPTION_TYPE_CHECKBOX,
125: 'order' => 8,
126: 'desc' => gettext('If checked, the defined <em>text</em> will be used in place of the icon. (Use the class <code>textasnewflag</code> for styling "text" overlays.)'))
127: );
128: }
129:
130: private static function insert_class($html) {
131: global $_zp_current_album, $_zp_current_image;
132: if (getOption('flag_thumbnail_flag_new')) {
133: if (isset($_zp_current_image)) {
134: $obj = $_zp_current_image;
135: } else {
136: $obj = $_zp_current_album;
137: }
138: $html = '<span class="flag_thumbnail" style="position:relative; display:block;">' . "\n" . $html . "\n";
139: switch (getOption('flag_thumbnail_date')) {
140: case "date":
141: $imagedatestamp = strtotime($obj->getDateTime());
142: break;
143: case "mtime":
144: $imagedatestamp = $obj->get('mtime');
145: break;
146: }
147: $not_older_as = (60 * 60 * 24 * getOption('flag_thumbnail_range'));
148: $age = (time() - $imagedatestamp);
149: if ($age <= $not_older_as) {
150: if (getOption('flag_thumbnail_use_text')) {
151: $text = getOption('flag_thumbnail_new_text');
152: $html .= '<span class="textasnewflag" style="position: absolute;top: 10px;right: 6px;">' . $text . "</span>\n";
153: } else {
154: $img = getPlugin('flag_thumbnail/' . getOption('flag_thumbnail_new_icon'), false, true);
155: $html .= '<img src="' . $img . '" class="imageasflag" alt="" style="position: absolute;top: 4px;right: 4px;"/>' . "\n";
156: }
157: }
158: }
159: if (getOption('flag_thumbnail_flag_geodata')) {
160: if (isAlbumClass($obj)) {
161: $obj = $obj->getAlbumThumbImage();
162: }
163: if (is_object($obj) && get_class($obj) == 'Image') {
164: $exif = $obj->getMetaData();
165: if (!empty($exif['EXIFGPSLatitude']) && !empty($exif['EXIFGPSLongitude'])) {
166: if (getOption('flag_thumbnail_use_text')) {
167: $text = getOption('flag_thumbnail_geodata_text');
168: $html .= '<span class="textasnewflag" style="position: absolute;bottom: 10px;right: 6px;">' . $text . "</span>\n";
169: } else {
170: $img = getPlugin('flag_thumbnail/' . getOption('flag_thumbnail_geodata_icon'), false, true);
171: $html .= '<img src="' . $img . '" class="imageasflag" alt="" style="position: absolute;bottom: 4px;right: 4px;"/>' . "\n";
172: }
173: }
174: }
175: }
176: $i = strpos($html, 'class=');
177: if ($i !== false) {
178: $locked = strpos($html, 'password_protected', $i + 7) !== false;
179: $unpublished = strpos($html, 'not_visible', $i + 7) !== false;
180:
181: if ($locked && getOption('flag_thumbnail_flag_locked')) {
182: if (getOption('flag_thumbnail_use_text')) {
183: $text = getOption('flag_thumbnail_locked_text');
184: $html .= '<span class="textasnewflag" style="position: absolute;bottom: 10px;left: 4px;">' . $text . "</span>\n";
185: } else {
186: $img = getPlugin('flag_thumbnail/' . getOption('flag_thumbnail_locked_icon'), false, true);
187: $html .= '<img src="' . $img . '" class="imageasflag" alt="" style="position: absolute;bottom: 4px;left: 4px;"/>' . "\n";
188: }
189: }
190: if ($unpublished && getOption('flag_thumbnail_flag_unpublished')) {
191: if (getOption('flag_thumbnail_use_text')) {
192: $text = getOption('flag_thumbnail_unpublished_text');
193: $html .= '<span class="textasnewflag" style="position: absolute;top: 10px;left: 4px;">' . $text . "</span>\n";
194: } else {
195: $img = getPlugin('flag_thumbnail/' . getOption('flag_thumbnail_unpublished_icon'), false, true);
196: $html .= '<img src="' . $img . '" class="imageasflag" alt="" style="position: absolute;top: 4px;left: 4px;"/>' . "\n";
197: }
198: }
199: }
200: $html .= "</span>\n";
201: return $html;
202: }
203:
204: static function custom_images($html, $thumbstandin) {
205: if ($thumbstandin) {
206: $html = flag_thumbnail::insert_class($html);
207: }
208: return $html;
209: }
210:
211: static function std_image_thumbs($html) {
212: $html = flag_thumbnail::insert_class($html);
213: return $html;
214: }
215:
216: static function std_album_thumbs($html) {
217: $html = flag_thumbnail::insert_class($html);
218: return $html;
219: }
220:
221: static function custom_album_thumbs($html) {
222: $html = flag_thumbnail::insert_class($html);
223: return $html;
224: }
225:
226: }
227:
228: ?>