]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Awesomeness/AwesomenessPlugin.php
0d7900064db16238ef0581bbf6a0f729d93deb8b
[quix0rs-gnu-social.git] / plugins / Awesomeness / AwesomenessPlugin.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Plugin to add adittional awesomenss to StatusNet
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Plugin
23  * @package   StatusNet
24  * @author    Jeroen De Dauw <jeroendedauw@gmail.com>
25  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
26  * @link      http://status.net/
27  */
28
29 if (!defined('STATUSNET')) {
30     exit(1);
31 }
32
33 /**
34  * Facebook plugin to add a StatusNet Facebook canvas application
35  * and allow registration and authentication via Facebook Connect
36  *
37  * @category Plugin
38  * @package  StatusNet
39  * @author   Jeroen De Dauw <jeroendedauw@gmail.com>
40  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41  * @link     http://status.net/
42  */
43
44 class AwesomenessPlugin extends Plugin
45 {
46         
47         const VERSION = '0.0.42';
48         
49     public function onPluginVersion(&$versions)
50     {
51         $versions[] = array(
52             'name' => 'Awesomeness',
53             'version' => self::VERSION,
54             'author' => 'Jeroen De Dauw',
55             'homepage' => 'http://status.net/wiki/Plugin:Awesomeness',
56             'rawdescription' => _m(
57                 'The Awesomeness plugin adds adittional awesomeness ' .
58                 'to your StatusNet install. '
59             )
60         );
61         return true;
62     }
63     
64     /**
65      * Add the conrnify button
66      *
67      * @param Action $action the current action
68      *
69      * @return void
70      */
71
72     function onEndShowSections(Action $action)
73     {   
74         $action->elementStart('div', array('id' => 'cornify_section',
75                                          'class' => 'section'));        
76         
77         $action->raw(
78         <<<EOT
79                 <a href="http://www.cornify.com" onclick="cornify_add();return false;">
80                 <img src="http://www.cornify.com/assets/cornify.gif" width="61" height="16" border="0" alt="Cornify" />
81                 </a>
82         <script type="text/javascript">(function() {
83         var js = document.createElement('script');
84         js.type = 'text/javascript';
85         js.async = true;
86         js.src = 'http://www.cornify.com/js/cornify.js';
87         (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(js);
88 })();</script>
89 EOT
90         );    
91         
92         $action->elementEnd('div');
93     }
94     
95     /**
96      * Hook for new-notice form processing to take our HTML goodies;
97      * won't affect API posting etc.
98      * 
99      * @param NewNoticeAction $action
100      * @param User $user
101      * @param string $content
102      * @param array $options
103      * @return boolean hook return
104      */
105     function onStartSaveNewNoticeWeb($action, $user, &$content, &$options)
106     {
107         $content = htmlspecialchars($content);
108         $options['rendered'] = preg_replace("/(^|\s|-)(awesome|awesomeness[\?!\.\,]?)(\s|$)/i", " <b>$2</b> ", $content);
109     }
110         
111 }