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