cvs: pear /Net_SmartIRC SmartIRC.php
| From: | Mirco 'meebey' Bauer | Date: | Sun, 20 Apr 2003 15:51:28 +0000 |
| Subject: | cvs: pear /Net_SmartIRC SmartIRC.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-9987@lists.php.net to get a copy of this message | ||
meebey Sun Apr 20 11:51:28 2003 EDT
Modified files:
/pear/Net_SmartIRC SmartIRC.php
Log:
- first implementation of module supprt.
Index: pear/Net_SmartIRC/SmartIRC.php
diff -u pear/Net_SmartIRC/SmartIRC.php:1.19 pear/Net_SmartIRC/SmartIRC.php:1.20
--- pear/Net_SmartIRC/SmartIRC.php:1.19 Fri Apr 18 15:57:34 2003
+++ pear/Net_SmartIRC/SmartIRC.php Sun Apr 20 11:51:27 2003
@@ -1,9 +1,9 @@
<?php
/**
- * $Id: SmartIRC.php,v 1.19 2003/04/18 19:57:34 meebey Exp $
- * $Revision: 1.19 $
+ * $Id: SmartIRC.php,v 1.20 2003/04/20 15:51:27 meebey Exp $
+ * $Revision: 1.20 $
* $Author: meebey $
- * $Date: 2003/04/18 19:57:34 $
+ * $Date: 2003/04/20 15:51:27 $
*
* Net_SmartIRC
* Communication for PHP with IRC networks
@@ -1401,10 +1401,10 @@
$this->listen();
$result = $listenfor->result;
- if (isset($listenfor)) {
- unset($listenfor);
- }
-
+ if (isset($listenfor)) {
+ unset($listenfor);
+ }
+
return $result;
}
@@ -1427,10 +1427,10 @@
$id = $this->_actionhandlerid++;
$newactionhandler = &new Net_SmartIRC_actionhandler();
- if (!$newactionhandler) {
- return false;
- }
-
+ if (!$newactionhandler) {
+ return false;
+ }
+
$newactionhandler->id = $id;
$newactionhandler->type = $handlertype;
$newactionhandler->message = $regexhandler;
@@ -1455,7 +1455,7 @@
function unregisterActionhandler($handlertype, $regexhandler, &$object, $methodname)
{
$handler = &$this->_actionhandler;
- $handlercount = count($handler);
+ $handlercount = count($handler);
for ($i=0; $i<$handlercount; $i++) {
$handlerobject = &$handler[$i];
@@ -1467,9 +1467,9 @@
$id = $handlerobject->id;
if (isset($this->_actionhandler[$i])) {
- unset($this->_actionhandler[$i]);
- }
-
+ unset($this->_actionhandler[$i]);
+ }
+
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER:
actionhandler('.$id.') unregistered');
$this->_reorderactionhandler();
return true;
@@ -1490,15 +1490,15 @@
function unregisterActionid($id)
{
$handler = &$this->_actionhandler;
- $handlercount = count($handler);
+ $handlercount = count($handler);
for ($i=0; $i<$handlercount; $i++) {
$handlerobject = &$handler[$i];
if ($handlerobject->id == $id) {
- if (isset($this->_actionhandler[$i])) {
+ if (isset($this->_actionhandler[$i])) {
unset($this->_actionhandler[$i]);
- }
-
+ }
+
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER:
actionhandler('.$id.') unregistered');
$this->_reorderactionhandler();
return true;
@@ -1529,8 +1529,8 @@
if (!$newtimehandler) {
return false;
- }
-
+ }
+
$newtimehandler->id = $id;
$newtimehandler->interval = $interval;
$newtimehandler->object = &$object;
@@ -1558,15 +1558,15 @@
function unregisterTimeid($id)
{
$handler = &$this->_timehandler;
- $handlercount = count($handler);
+ $handlercount = count($handler);
for ($i=0; $i<$handlercount; $i++) {
$handlerobject = &$handler[$i];
if ($handlerobject->id == $id) {
- if (isset($this->_timehandler[$i])) {
- unset($this->_timehandler[$i]);
- }
-
+ if (isset($this->_timehandler[$i])) {
+ unset($this->_timehandler[$i]);
+ }
+
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER:
timehandler('.$id.') unregistered');
$this->_reordertimehandler();
$this->_updatemintimer();
@@ -1579,23 +1579,24 @@
}
// experimentel feature, do not use it yet!
- function loadModule($filename)
+ function loadModule($name)
{
- $fullfilename = 'modules/'.$filename;
- if (@file_exists($fullfilename)) {
- $this->log(SMARTIRC_DEBUG_MODULES, 'SMARTIRC_DEBUG_MODULES: loading module
'.$filename);
- include_once($fullfilename);
+ $filename =
'/home/meebey/data/projects/SmartIRC/cvs-php/pear/Net_SmartIRC/SmartIRC/modules/'.$name.'.php';
+ if (file_exists($filename)) {
+ $this->log(SMARTIRC_DEBUG_MODULES, 'SMARTIRC_DEBUG_MODULES: loading module
'.$name);
+ include_once($filename);
// now we have to check what we included
// TODO: later
- $extpos = strpos($filename, '.php');
- $classname = substr($filename, 0, strlen($filename)-$extpos);
+ $classname = 'Net_SmartIRC_module_'.$name;
- if ($found_name && $found_description && $found_autor) {
+ if (class_exists($classname)) {
+ $module = &new $classname;
+ $module->module_init($this);
return true;
- } else {
- return false;
}
+
+ return false;
} else {
$this->log(SMARTIRC_DEBUG_MODULES, 'SMARTIRC_DEBUG_MODULES: couldn\'t
loading module '.$filename.' file doesn\'t exist');
return false;
@@ -1891,8 +1892,8 @@
}
if (isset($ircdata)) {
- unset($ircdata);
- }
+ unset($ircdata);
+ }
}
}
}
@@ -2234,7 +2235,7 @@
function _handleactionhandler(&$ircdata)
{
$handler = &$this->_actionhandler;
- $handlercount = count($handler);
+ $handlercount = count($handler);
for ($i=0; $i<$handlercount; $i++) {
$handlerobject = &$handler[$i];
@@ -2395,7 +2396,7 @@
// </private methods>
function isError($object) {
- return (bool)(is_object($object) && (get_class($object) ==
'net_smartirc_error'));
+ return (bool)(is_object($object) && (get_class($object) ==
'net_smartirc_error'));
}
function &throwError($message) {