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
|
<?php
/**
* @version $Revision$
* @package liberty
* @subpackage plugins_data
*/
/**
* definitions
*/
global $gLibertySystem;
define( 'PLUGIN_GUID_DATAGOOGLEVIEWER', 'datagoogleviewer' );
$pluginParams = array (
'tag' => 'GOOGLEVIEWER',
'auto_activate' => FALSE,
'requires_pair' => FALSE,
'load_function' => 'data_googleviewer',
'title' => 'Google Viewer',
'help_page' => 'DataPluginGoogleviewer',
'description' => tra( "This plugin allows you to simply embed a PDF document in a page using the embeddable Google Viewer." ),
'help_function' => 'data_googleviewer_help',
'syntax' => "{googleviewer url=}",
'plugin_type' => DATA_PLUGIN
);
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAGOOGLEVIEWER, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAGOOGLEVIEWER );
/**
* data_googleviewer_help
*
* @access public
* @return HTML help in a table
*/
function data_googleviewer_help() {
return
'<table class="data help">'
.'<tr>'
.'<th>' . tra( "Key" ) . '</th>'
.'<th>' . tra( "Type" ) . '</th>'
.'<th>' . tra( "Comments" ) . '</th>'
.'</tr>'
.'<tr class="odd">'
.'<td>url</td>'
.'<td>' . tra( "string" ) . '<br />' . tra("(required)") . '</td>'
.'<td>' . tra( "URL of the PDF online" ) . '</td>'
.'</tr>'
.'<tr class="even">'
.'<td>width</td>'
.'<td>' . tra( "numeric" ) . '<br />' . tra( "(optional)" ) . '</td>'
.'<td>' . tra( "Alternate width of the Google Viewer box in pixels. Default is 100%." ) . '</td>'
.'</tr>'
.'<tr class="odd">'
.'<td>height</td>'
.'<td>' . tra( "numeric" ) . '<br />' . tra("(optional)") . '</td>'
.'<td>' . tra( "Alternate height of the Google Viewer box in pixels. Default is 650." ) . '</td>'
.'</tr>'
.'</table>'
. tra( "Example: " ) . '{googleviewer url=XXXXX width=425 height=355}';
}
/**
* data_googleviewer
*
* @param array $pData
* @param array $pParams
* @access public
* @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
*/
function data_googleviewer( $pData, $pParams ) {
extract( $pParams );
$width = ( !empty( $width ) ? $width : "100%" );
$height = ( !empty( $height ) ? $height : "650" );
if( !empty( $url )) {
return '<!--~np~--><iframe width="'.$width.'" height="'.$height.'" style="border:none;" src="http://docs.google.com/viewer?embedded=true&url='.urlencode($url).'"></iframe><!--~/np~-->';
} else {
return tra( 'No URL given' );
}
}
?>
|