]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Awesomeness/AwesomenessPlugin.php
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
[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  * Fun sample plugin: tweaks input data and adds a 'Cornify' widget to sidebar.
35  *
36  * @category Plugin
37  * @package  StatusNet
38  * @author   Jeroen De Dauw <jeroendedauw@gmail.com>
39  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
40  * @link     http://status.net/
41  */
42
43 class AwesomenessPlugin extends Plugin
44 {
45         
46         const VERSION = '0.0.42';
47         
48     public function onPluginVersion(&$versions)
49     {
50         $versions[] = array(
51             'name' => 'Awesomeness',
52             'version' => self::VERSION,
53             'author' => 'Jeroen De Dauw',
54             'homepage' => 'http://status.net/wiki/Plugin:Awesomeness',
55             'rawdescription' => _m(
56                 'The Awesomeness plugin adds adittional awesomeness ' .
57                 'to your StatusNet install. '
58             )
59         );
60         return true;
61     }
62     
63     /**
64      * Add the conrnify button
65      *
66      * @param Action $action the current action
67      *
68      * @return void
69      */
70
71     function onEndShowSections(Action $action)
72     {   
73         $action->elementStart('div', array('id' => 'cornify_section',
74                                          'class' => 'section'));        
75         
76         $action->raw(
77         <<<EOT
78                 <a href="http://www.cornify.com" onclick="cornify_add();return false;">
79                 <img src="http://www.cornify.com/assets/cornify.gif" width="61" height="16" border="0" alt="Cornify" />
80                 </a>
81         <script type="text/javascript">(function() {
82         var js = document.createElement('script');
83         js.type = 'text/javascript';
84         js.async = true;
85         js.src = 'http://www.cornify.com/js/cornify.js';
86         (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(js);
87 })();</script>
88 EOT
89         );    
90         
91         $action->elementEnd('div');
92     }
93     
94     /**
95      * Hook for new-notice form processing to take our HTML goodies;
96      * won't affect API posting etc.
97      * 
98      * @param NewNoticeAction $action
99      * @param User $user
100      * @param string $content
101      * @param array $options
102      * @return boolean hook return
103      */
104     function onStartSaveNewNoticeWeb($action, $user, &$content, &$options)
105     {
106         $content = htmlspecialchars($content);
107         $options['rendered'] = preg_replace("/(^|\s|-)((?:awesome|awesomeness)[\?!\.\,]?)(\s|$)/i", " <b>$2</b> ", $content);
108     }
109         
110 }