-
Notifications
You must be signed in to change notification settings - Fork 0
/
diigosilo.plugin.php
191 lines (166 loc) · 4.61 KB
/
diigosilo.plugin.php
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
/**
* Provides a silo to access Diigo bookmarks.
*
* @category PHP
* @package diigosilo
* @author Pierre-Yves Gillier <pivwan@gmail.com>
* @copyright 2008 Pierre-Yves Gillier
* @license http://www.apache.org/licenses/LICENSE-2.0.txt Apache Software Licence 2.0
* @version 0.2
* @link http://www.pivwan.net/weblog/plugin-diigosilo
*/
// Load used classes.
include_once(dirname(__FILE__).'/httpClient.class.php');
include_once(dirname(__FILE__).'/diigo.class.php');
define('DIIGO_PLUGIN_VERSION','0.2');
class DiigoSilo extends Plugin implements MediaSilo
{
const SILO_NAME = 'Diigo';
static $cache = array();
/**
* Provide plugin info to the system
*/
public function info()
{
return array('name' => 'Diigo Media Silo',
'version' => DIIGO_PLUGIN_VERSION,
'url' => 'http://www.pivwan.net/weblog/plugin-diigosilo/',
'author' => 'Pierre-Yves "pivwan" Gillier',
'authorurl' => 'http://www.pivwan.net/weblog/',
'license' => 'Apache Software License 2.0',
'description' => 'Implements Diigo integration',
'copyright' => '2008',
);
}
public function is_auth()
{
return true;
}
/**
* Return basic information about this silo
* name- The name of the silo, used as the root directory for media in this silo
*/
public function silo_info()
{
if($this->is_auth()) {
return array('name' => self::SILO_NAME);
}
else {
return array();
}
}
public function silo_dir($path)
{
$section = strtok($path, '/');
$results = array();
$diigo = new DiigoAPI(Options::get('diigosilo__username_' . User::identify()->id),Options::get('diigosilo__password_' . User::identify()->id));
switch($section)
{
case 'bookmarks':
$bookmarks = $diigo->getBookmarks();
foreach($bookmarks as $bookmark)
{
$results[] = new MediaAsset(
self::SILO_NAME.'/bookmarks/'.base64_encode($bookmark->url),
false,
array(
'title' => $bookmark->title,'filetype'=>'diigo',
'link_url' => $bookmark->url,
)
);
}
break;
case 'tags':
//$tags = $diigo->getTags();
$results[] = new MediaAsset(
self::SILO_NAME . '/tags/' . "demo",
true,
array( 'title'=>'Tag de démo' )
);
break;
case '':
$results[] = new MediaAsset(
self::SILO_NAME . '/bookmarks',
true,
array( 'title' => _t('Bookmarks') )
);
$results[] = new MediaAsset(
self::SILO_NAME . '/tags',
true,
array( 'title' => _t('Tags') )
);
$results[] = new MediaAsset(
self::SILO_NAME . '/lists',
true,
array( 'title' => _t('Lists') )
);
break;
}
return $results;
}
public function silo_get( $path, $qualities = null )
{
}
public function silo_put( $path, $filedata )
{
}
public function silo_delete( $path )
{
}
public function silo_highlights() {}
public function silo_permissions( $path ) {}
// PLUGIN FUNCTIONS
/**
* Add actions to the plugin page for this plugin
* The authorization should probably be done per-user.
*
* @param array $actions An array of actions that apply to this plugin
* @param string $plugin_id The string id of a plugin, generated by the system
* @return array The array of actions to attach to the specified $plugin_id
*/
public function filter_plugin_config($actions, $plugin_id)
{
if ($plugin_id == $this->plugin_id())
{
$actions[] = _t('Configure');
}
return $actions;
}
public function action_plugin_ui($plugin_id, $action)
{
if ($plugin_id == $this->plugin_id())
{
switch ($action)
{
case _t('Configure'):
$ui = new FormUI(strtolower(get_class($this)));
$username = $ui->append( 'text', 'username_'.User::identify()->id, 'diigosilo__username_'.User::identify()->id, _t('Username:') );
$password = $ui->append( 'password', 'password_'.User::identify()->id, 'diigosilo__password_'.User::identify()->id, _t('Password:') );
$ui->append( 'submit', 'save', _t('Save') );
$ui->out();
break;
}
}
}
public function updated_config($ui)
{
return true;
}
public function action_admin_footer( $theme ) {
if ($theme->page == 'publish') {
echo <<< DIIGO
<script type="text/javascript">
habari.media.output.diigo = function(fileindex, fileobj) {
habari.editor.insertSelection('<a href="' + fileobj.link_url + '">' + fileobj.title + '</a>');
}
habari.media.preview.diigo = function(fileindex, fileobj) {
var stats = '';
return '<div class="mediatitle">' + fileobj.title + '</div><div class="mediastats"><a href="' + fileobj.link_url + '">Link</a></div>';
}
</script>
DIIGO;
}
}
}
?>