]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Bookmark/BookmarkPlugin.php
save title and description of bookmark
[quix0rs-gnu-social.git] / plugins / Bookmark / BookmarkPlugin.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
6  * A plugin to enable social-bookmarking functionality
7  *
8  * PHP version 5
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  SocialBookmark
24  * @package   StatusNet
25  * @author    Evan Prodromou <evan@status.net>
26  * @copyright 2010 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET')) {
32         exit(1);
33 }
34
35 /**
36  * Bookmark plugin main class
37  *
38  * @category  Bookmark
39  * @package   StatusNet
40  * @author    Brion Vibber <brionv@status.net>
41  * @author    Evan Prodromou <evan@status.net>
42  * @copyright 2010 StatusNet, Inc.
43  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
44  * @link      http://status.net/
45  */
46
47 class BookmarkPlugin extends Plugin
48 {
49         /**
50          * Database schema setup
51          *
52          * @see Schema
53          * @see ColumnDef
54          *
55          * @return boolean hook value; true means continue processing, false means stop.
56          */
57
58         function onCheckSchema()
59         {
60                 $schema = Schema::get();
61
62                 // For storing user-submitted flags on profiles
63
64                 $schema->ensureTable('notice_bookmark',
65                                                          array(new ColumnDef('notice_id',
66                                                                                                  'integer',
67                                                                                                  null,
68                                                                                                  true,
69                                                                                                  'PRI'),
70                                                                    new ColumnDef('title',
71                                                                                                  'varchar',
72                                                                                                  255),
73                                                                    new ColumnDef('description',
74                                                                                                  'text')));
75
76                 return true;
77         }
78
79         /**
80          * Load related modules when needed
81          *
82          * @param string $cls Name of the class to be loaded
83          *
84          * @return boolean hook value; true means continue processing, false means stop.
85          */
86
87         function onAutoload($cls)
88         {
89                 $dir = dirname(__FILE__);
90
91                 switch ($cls)
92                 {
93                 case 'NewbookmarkAction':
94                         include_once $dir.'/newbookmark.php';
95                         return false;
96                 case 'Notice_bookmark':
97                         include_once $dir.'/'.$cls.'.php';
98                         return false;
99                 case 'BookmarkForm':
100                         include_once $dir.'/'.strtolower($cls).'.php';
101                         return false;
102                 default:
103                         return true;
104                 }
105         }
106
107         /**
108          * Map URLs to actions
109          *
110          * @param Net_URL_Mapper $m path-to-action mapper
111          *
112          * @return boolean hook value; true means continue processing, false means stop.
113          */
114
115         function onRouterInitialized($m)
116         {
117                 $m->connect('main/bookmark/new',
118                                         array('action' => 'newbookmark'),
119                                         array('id' => '[0-9]+'));
120
121                 return true;
122         }
123
124         function onPluginVersion(&$versions)
125         {
126                 $versions[] = array('name' => 'Sample',
127                                                         'version' => STATUSNET_VERSION,
128                                                         'author' => 'Evan Prodromou',
129                                                         'homepage' => 'http://status.net/wiki/Plugin:Bookmark',
130                                                         'rawdescription' =>
131                                                         _m('Simple extension for supporting bookmarks.'));
132                 return true;
133         }
134 }
135