1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16: $plugin_is_filter = 990 | CLASS_PLUGIN;
17: $plugin_description = gettext('Provides a means for handling arbitrary file types. (No rendering provided!)');
18: $plugin_author = "Stephen Billard (sbillard)";
19:
20:
21: foreach (get_AnyFile_suffixes() as $suffix) {
22: Gallery::addImageHandler($suffix, 'AnyFile');
23: }
24: $option_interface = 'AnyFile_Options';
25:
26: 27: 28: 29:
30: class AnyFile_Options {
31:
32: 33: 34: 35: 36:
37: function getOptionsSupported() {
38: return array(gettext('Watermark default images') => array('key' => 'AnyFile_watermark_default_images', 'type' => OPTION_TYPE_CHECKBOX,
39: 'desc' => gettext('Check to place watermark image on default thumbnail images.')),
40: gettext('Handled files') => array('key' => 'AnyFile_file_list', 'type' => OPTION_TYPE_CUSTOM,
41: 'desc' => gettext('File suffixes to be handled.')),
42: gettext('Add file suffix') => array('key' => 'AnyFile_file_new', 'type' => OPTION_TYPE_TEXTBOX,
43: 'desc' => gettext('Add a file suffix to be handled by the plugin'))
44: );
45: }
46:
47: function handleOption($option, $currentValue) {
48: $list = get_AnyFile_suffixes();
49: ?>
50: <ul class="customchecklist">
51: <?php
52: generateUnorderedListFromArray($list, $list, 'AnyFile_file_list_', false, false, false);
53: ?>
54: </ul>
55: <?php
56: }
57:
58: function handleOptionSave($themename, $themealbum) {
59: $mysetoptions = array();
60: foreach ($_POST as $key => $option) {
61: if (strpos($key, 'AnyFile_file_list_') === 0) {
62: $mysetoptions[] = str_replace('AnyFile_file_list_', '', $key);
63: purgeOption($key);
64: }
65: }
66: if ($_POST['AnyFile_file_new']) {
67: $mysetoptions[] = sanitize($_POST['AnyFile_file_new']);
68: $suffix = getOption('AnyFile_file_new');
69: purgeOption('AnyFile_file_new');
70: }
71: setOption('AnyFileSuffixList', serialize($mysetoptions));
72: return false;
73: }
74:
75: }
76:
77: function get_AnyFile_suffixes() {
78: $mysetoptions = array();
79: return getSerializedArray(getOption('AnyFileSuffixList'));
80: }
81:
82: require_once(dirname(__FILE__) . '/class-textobject/class-textobject_core.php');
83:
84: class AnyFile extends TextObject {
85:
86: 87: 88: 89: 90: 91: 92:
93: function __construct($album, $filename, $quiet = false) {
94:
95: $this->watermark = getOption('AnyFile_watermark');
96: $this->watermarkDefault = getOption('AnyFile_watermark_default_images');
97:
98: $this->common_instantiate($album, $filename, $quiet);
99: }
100:
101: 102: 103: 104: 105: 106: 107:
108: function getThumbImageFile($path = NULL) {
109: global $_zp_gallery;
110: if (is_null($path)) {
111: $path = SERVERPATH;
112: }
113: if (is_null($this->objectsThumb)) {
114: $img = '/' . getSuffix($this->filename) . 'Default.png';
115: $imgfile = $path . '/' . THEMEFOLDER . '/' . internalToFilesystem($_zp_gallery->getCurrentTheme()) . '/images/' . $img;
116: if (!file_exists($imgfile)) {
117: $imgfile = $path . "/" . USER_PLUGIN_FOLDER . '/' . substr(basename(__FILE__), 0, -4) . $img;
118: if (!file_exists($imgfile)) {
119: $imgfile = $path . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . substr(basename(__FILE__), 0, -4) . '/anyFileDefault.png';
120: }
121: }
122: } else {
123: $imgfile = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($this->imagefolder) . '/' . $this->objectsThumb;
124: }
125: return $imgfile;
126: }
127:
128: 129: 130: 131: 132: 133: 134:
135: function getContent($w = NULL, $h = NULL) {
136: $this->updateDimensions();
137: if (is_null($w))
138: $w = $this->getWidth();
139: if (is_null($h))
140: $h = $this->getHeight();
141: 142: 143: 144:
145: return '<img src="' . html_encode(pathurlencode($this->getThumb())) . '">';
146: }
147:
148: }
149: ?>