]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Irc/extlib/phergie/Phergie/Plugin/Php.php
Cosmetic whitespace change
[quix0rs-gnu-social.git] / plugins / Irc / extlib / phergie / Phergie / Plugin / Php.php
1 <?php
2 /**
3  * Phergie 
4  *
5  * PHP version 5
6  *
7  * LICENSE
8  *
9  * This source file is subject to the new BSD license that is bundled
10  * with this package in the file LICENSE.
11  * It is also available through the world-wide-web at this URL:
12  * http://phergie.org/license
13  *
14  * @category  Phergie 
15  * @package   Phergie_Plugin_Php
16  * @author    Phergie Development Team <team@phergie.org>
17  * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
18  * @license   http://phergie.org/license New BSD License
19  * @link      http://pear.phergie.org/package/Phergie_Plugin_Php
20  */
21
22 /**
23  * Returns information on PHP functions as requested. 
24  *
25  * @category Phergie 
26  * @package  Phergie_Plugin_Php
27  * @author   Phergie Development Team <team@phergie.org>
28  * @license  http://phergie.org/license New BSD License
29  * @link     http://pear.phergie.org/package/Phergie_Plugin_Php
30  * @uses     extension pdo 
31  * @uses     extension pdo_sqlite 
32  * @uses     Phergie_Plugin_Command pear.phergie.org
33  */
34 class Phergie_Plugin_Php extends Phergie_Plugin_Abstract
35 {
36     /**
37      * Data source to use
38      *
39      * @var Phergie_Plugin_Php_Source
40      */
41     protected $source;
42
43     /**
44      * Check for dependencies.
45      *
46      * @return void
47      */
48     public function onLoad()
49     {
50         // @todo find a way to move this to Phergie_Plugin_Php_Source_Local
51         if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) {
52             $this->fail('PDO and pdo_sqlite extensions must be installed');
53         }
54
55         $this->getPluginHandler()->getPlugin('Command');
56     }
57
58     /**
59      * Initializes the data source. 
60      *
61      * @return void
62      */
63     public function onConnect()
64     {
65         $this->source = new Phergie_Plugin_Php_Source_Local;
66     }
67
68     /**
69      * Searches the data source for the requested function.
70      * 
71      * @param string $functionName Name of the function to search for
72      *
73      * @return void
74      */
75     public function onCommandPhp($functionName)
76     {
77         $nick = $this->event->getNick();
78         if ($function = $this->source->findFunction($functionName)) {
79             $msg = $nick . ': ' . $function['description'];
80             $this->doPrivmsg($this->event->getSource(), $msg);
81         } else {
82             $msg = 'Search for function ' . $functionName . ' returned no results.';
83             $this->doNotice($nick, $msg);
84         }
85     }
86 }