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: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174:
<?php
$plugin_is_filter = 990 | CLASS_PLUGIN;
$plugin_description = gettext('Provides a means for showing documents using <em>WEBdocs</em> for the document rendering.');
$plugin_author = "Stephen Billard (sbillard)";
$plugin_notice = gettext('Privacy note: This plugin uses external third party sources');
$plugin_category = gettext('Media');
$option_interface = 'WEBdocs_Options';
if (getOption('WEBdocs_pdf_provider')) {
Gallery::addImageHandler('pdf', 'WEBdocs');
}
if (getOption('WEBdocs_pps_provider')) {
Gallery::addImageHandler('pps', 'WEBdocs');
Gallery::addImageHandler('ppt', 'WEBdocs');
}
if (getOption('WEBdocs_tif_provider')) {
Gallery::addImageHandler('tif', 'WEBdocs');
Gallery::addImageHandler('tiff', 'WEBdocs');
}
class WEBdocs_Options {
function __construct() {
setOptionDefault('WEBdocs_pdf_provider', 'local');
setOptionDefault('WEBdocs_pps_provider', 'google');
setOptionDefault('WEBdocs_tif_provider', 'zoho');
}
function getOptionsSupported() {
return array(gettext('Watermark default images') => array('key' => 'WEBdocs_watermark_default_images', 'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext('Check to place watermark image on default thumbnail images.')),
gettext('PDF') => array('key' => 'WEBdocs_pdf_provider', 'type' => OPTION_TYPE_RADIO,
'buttons' => array(gettext('Disabled') => '',
gettext('GoogleDocs') => 'google',
gettext('Zoho') => 'zoho',
gettext('Browser default') => 'local'
),
'desc' => gettext("Choose the WEB service to use for rendering pdf documents.") .
'<p>' . sprintf(gettext('Select <em>google</em> to use the <a href="%s">GoogleDocs viewer</a>'), 'http://docs.google.com/viewer') . '</p>' .
'<p>' . sprintf(gettext('Select <em>zoho</em> to use the <a href="%s">Zoho document viewer</a>'), 'http://viewer.zoho.com/home.do') . '</p>' .
'<p>' . gettext('Select <em>Browser default</em> to use the your browser default application') . '</p>'
),
gettext('PowerPoint') => array('key' => 'WEBdocs_pps_provider', 'type' => OPTION_TYPE_RADIO,
'buttons' => array(gettext('Disabled') => '',
gettext('GoogleDocs') => 'google',
gettext('Zoho') => 'zoho',
gettext('Browser default') => 'local'
),
'desc' => gettext("Choose the WEB service to use for rendering PowerPoint document.")),
gettext('Tiff') => array('key' => 'WEBdocs_tif_provider', 'type' => OPTION_TYPE_RADIO,
'buttons' => array(gettext('Disabled') => '',
gettext('Zoho') => 'zoho',
gettext('Browser default') => 'local'
),
'desc' => gettext("Choose the WEB service to use for rendering TIFF images."))
);
}
}
require_once(dirname(__FILE__) . '/class-textobject/class-textobject_core.php');
class WEBdocs extends TextObject {
function __construct($album, $filename, $quiet = false) {
$this->watermark = getOption('WEBdocs_watermark');
$this->watermarkDefault = getOption('WEBdocs_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)) {
switch (getSuffix($this->filename)) {
case "pdf":
$img = '/pdfDefault.png';
break;
case 'ppt':
case 'pps':
$img = '/ppsDefault.png';
break;
case 'tif':
case 'tiff':
$img = '/tifDefault.png';
break;
}
$imgfile = $path . '/' . THEMEFOLDER . '/' . internalToFilesystem($_zp_gallery->getCurrentTheme()) . '/images/' . $img;
if (!file_exists($imgfile)) {
$imgfile = $path . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . substr(basename(__FILE__), 0, -4) . '/' . $img;
}
} 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();
$providers = array('' => '<img src="' . html_encode(pathurlencode($this->getThumb())) . '">',
'google' => '<iframe src="http://docs.google.com/viewer?url=%s&embedded=true" width="' . $w . 'px" height="' . $h . 'px" frameborder="0" border="none" scrolling="auto"></iframe>',
'zoho' => '<iframe src="http://viewer.zoho.com/api/urlview.do?url=%s&embed=true" width="' . $w . 'px" height="' . $h . 'px" frameborder="0" border="none" scrolling="auto"></iframe>',
'local' => '<iframe src="%s" width="' . $w . 'px" height="' . $h . 'px" frameborder="0" border="none" scrolling="auto"></iframe>'
);
switch ($suffix = getSuffix($this->filename)) {
case 'ppt':
$suffix = 'pps';
case 'tiff':
$suffix = substr($suffix, 0, 3);
case 'tif':
case 'pps':
case 'pdf':
$provider = 'WEBdocs_' . $suffix . '_provider';
return sprintf($providers[getOption($provider)], html_encode($this->getFullImage(FULLWEBPATH)));
default:
return '<img src="' . html_encode(pathurlencode($this->getThumb())) . '">';
}
}
}
?>