gnu-social/plugins/Irc/extlib/phergie/Phergie/Plugin/Php.php

79 lines
2.2 KiB
PHP
Raw Normal View History

2010-06-16 09:55:39 +09:00
<?php
/**
* Phergie
*
* PHP version 5
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.
* It is also available through the world-wide-web at this URL:
* http://phergie.org/license
*
* @category Phergie
* @package Phergie_Plugin_Php
* @author Phergie Development Team <team@phergie.org>
* @copyright 2008-2010 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie_Plugin_Php
*/
/**
* Returns information on PHP functions as requested.
*
* @category Phergie
* @package Phergie_Plugin_Php
* @author Phergie Development Team <team@phergie.org>
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie_Plugin_Php
* @uses extension pdo
* @uses extension pdo_sqlite
* @uses Phergie_Plugin_Command pear.phergie.org
*/
class Phergie_Plugin_Php extends Phergie_Plugin_Abstract
{
/**
* Data source to use
*
* @var Phergie_Plugin_Php_Source
*/
protected $source;
/**
* Check for dependencies.
*
* @return void
*/
public function onLoad()
{
// @todo find a way to move this to Phergie_Plugin_Php_Source_Local
if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) {
$this->fail('PDO and pdo_sqlite extensions must be installed');
}
$this->getPluginHandler()->getPlugin('Command');
$this->source = new Phergie_Plugin_Php_Source_Local;
}
/**
* Searches the data source for the requested function.
*
* @param string $functionName Name of the function to search for
*
* @return void
*/
public function onCommandPhp($functionName)
{
2010-07-01 01:33:29 +09:00
$nick = $this->event->getNick();
2010-06-16 09:55:39 +09:00
if ($function = $this->source->findFunction($functionName)) {
2010-07-01 01:33:29 +09:00
$msg = $nick . ': ' . $function['description'];
$this->doPrivmsg($this->event->getSource(), $msg);
2010-06-16 09:55:39 +09:00
} else {
$msg = 'Search for function ' . $functionName . ' returned no results.';
2010-07-01 01:33:29 +09:00
$this->doNotice($nick, $msg);
2010-06-16 09:55:39 +09:00
}
}
}