]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Irc/extlib/phergie/Phergie/Plugin/Php.php
Documentation + filename uniqueness in File class
[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         $this->source = new Phergie_Plugin_Php_Source_Local;
58     }
59
60     /**
61      * Searches the data source for the requested function.
62      * 
63      * @param string $functionName Name of the function to search for
64      *
65      * @return void
66      */
67     public function onCommandPhp($functionName)
68     {
69         $nick = $this->event->getNick();
70         if ($function = $this->source->findFunction($functionName)) {
71             $msg = $nick . ': ' . $function['description'];
72             $this->doPrivmsg($this->event->getSource(), $msg);
73         } else {
74             $msg = 'Search for function ' . $functionName . ' returned no results.';
75             $this->doNotice($nick, $msg);
76         }
77     }
78 }