1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: $plugin_is_filter = 990 | CLASS_PLUGIN;
16: $plugin_description = gettext('Provides a means for showing documents using <em>WEBdocs</em> for the document rendering.');
17: $plugin_author = "Stephen Billard (sbillard)";
18:
19:
20: $option_interface = 'WEBdocs_Options';
21:
22: if (getOption('WEBdocs_pdf_provider')) {
23: Gallery::addImageHandler('pdf', 'WEBdocs');
24: }
25: if (getOption('WEBdocs_pps_provider')) {
26: Gallery::addImageHandler('pps', 'WEBdocs');
27: Gallery::addImageHandler('ppt', 'WEBdocs');
28: }
29: if (getOption('WEBdocs_tif_provider')) {
30: Gallery::addImageHandler('tif', 'WEBdocs');
31: Gallery::addImageHandler('tiff', 'WEBdocs');
32: }
33:
34: 35: 36: 37:
38: class WEBdocs_Options {
39:
40: function __construct() {
41: setOptionDefault('WEBdocs_pdf_provider', 'local');
42: setOptionDefault('WEBdocs_pps_provider', 'google');
43: setOptionDefault('WEBdocs_tif_provider', 'zoho');
44: }
45:
46: 47: 48: 49: 50:
51: function getOptionsSupported() {
52: return array(gettext('Watermark default images') => array('key' => 'WEBdocs_watermark_default_images', 'type' => OPTION_TYPE_CHECKBOX,
53: 'desc' => gettext('Check to place watermark image on default thumbnail images.')),
54: gettext('PDF') => array('key' => 'WEBdocs_pdf_provider', 'type' => OPTION_TYPE_RADIO,
55: 'buttons' => array(gettext('Disabled') => '',
56: gettext('GoogleDocs') => 'google',
57: gettext('Zoho') => 'zoho',
58: gettext('Browser default') => 'local'
59: ),
60: 'desc' => gettext("Choose the WEB service to use for rendering pdf documents.") .
61: '<p>' . sprintf(gettext('Select <em>google</em> to use the <a href="%s">GoogleDocs viewer</a>'), 'http://docs.google.com/viewer') . '</p>' .
62: '<p>' . sprintf(gettext('Select <em>zoho</em> to use the <a href="%s">Zoho document viewer</a>'), 'http://viewer.zoho.com/home.do') . '</p>' .
63: '<p>' . gettext('Select <em>Browser default</em> to use the your browser default application') . '</p>'
64: ),
65: gettext('PowerPoint') => array('key' => 'WEBdocs_pps_provider', 'type' => OPTION_TYPE_RADIO,
66: 'buttons' => array(gettext('Disabled') => '',
67: gettext('GoogleDocs') => 'google',
68: gettext('Zoho') => 'zoho',
69: gettext('Browser default') => 'local'
70: ),
71: 'desc' => gettext("Choose the WEB service to use for rendering PowerPoint document.")),
72: gettext('Tiff') => array('key' => 'WEBdocs_tif_provider', 'type' => OPTION_TYPE_RADIO,
73: 'buttons' => array(gettext('Disabled') => '',
74: gettext('Zoho') => 'zoho',
75: gettext('Browser default') => 'local'
76: ),
77: 'desc' => gettext("Choose the WEB service to use for rendering TIFF images."))
78: );
79: }
80:
81: }
82:
83: require_once(dirname(__FILE__) . '/class-textobject/class-textobject_core.php');
84:
85: class WEBdocs extends TextObject {
86:
87: 88: 89: 90: 91: 92: 93:
94: function __construct($album, $filename, $quiet = false) {
95:
96: $this->watermark = getOption('WEBdocs_watermark');
97: $this->watermarkDefault = getOption('WEBdocs_watermark_default_images');
98:
99: $this->common_instantiate($album, $filename, $quiet);
100: }
101:
102: 103: 104: 105: 106: 107: 108:
109: function getThumbImageFile($path = NULL) {
110: global $_zp_gallery;
111: if (is_null($path)) {
112: $path = SERVERPATH;
113: }
114: if (is_null($this->objectsThumb)) {
115: switch (getSuffix($this->filename)) {
116: case "pdf":
117: $img = '/pdfDefault.png';
118: break;
119: case 'ppt':
120: case 'pps':
121: $img = '/ppsDefault.png';
122: break;
123: case 'tif':
124: case 'tiff':
125: $img = '/tifDefault.png';
126: break;
127: }
128: $imgfile = $path . '/' . THEMEFOLDER . '/' . internalToFilesystem($_zp_gallery->getCurrentTheme()) . '/images/' . $img;
129: if (!file_exists($imgfile)) {
130: $imgfile = $path . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . substr(basename(__FILE__), 0, -4) . '/' . $img;
131: }
132: } else {
133: $imgfile = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($this->imagefolder) . '/' . $this->objectsThumb;
134: }
135: return $imgfile;
136: }
137:
138: 139: 140: 141: 142: 143: 144:
145: function getContent($w = NULL, $h = NULL) {
146: $this->updateDimensions();
147: if (is_null($w))
148: $w = $this->getWidth();
149: if (is_null($h))
150: $h = $this->getHeight();
151: $providers = array('' => '<img src="' . html_encode(pathurlencode($this->getThumb())) . '">',
152: '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>',
153: '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>',
154: 'local' => '<iframe src="%s" width="' . $w . 'px" height="' . $h . 'px" frameborder="0" border="none" scrolling="auto"></iframe>'
155: );
156: switch ($suffix = getSuffix($this->filename)) {
157: case 'ppt':
158: $suffix = 'pps';
159: case 'tiff':
160: $suffix = substr($suffix, 0, 3);
161: case 'tif':
162: case 'pps':
163: case 'pdf':
164: $provider = 'WEBdocs_' . $suffix . '_provider';
165: return sprintf($providers[getOption($provider)], html_encode($this->getFullImage(FULLWEBPATH)));
166: default:
167: return '<img src="' . html_encode(pathurlencode($this->getThumb())) . '">';
168: }
169: }
170:
171: }
172:
173: ?>