add function buildCommandList to Plugins_Abstract
[irbot.git] / sources / Plugins / Abstract.php
blobc8d82edce1f09d12e8884dd69c1a87ca5b3c67b7
1 <?php
2 /**
3 * This file is part of IrBot, irc robot.
4 * Copyright (C) 2007 Bellière Ludovic
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 abstract class Plugins_Abstract extends RecursiveDirectoryIterator {
23 private $_message, $_commands;
25 protected $_commandsPath = 'plugins/%pluginName%/';
27 final public function __construct($path, $flags=0) {
28 parent::__construct($path,$flags);
29 self::init();
31 public function init() {
33 public function commands_list() {}
35 public function buildCommandList() {
36 while(self::valid()) {
37 if (self::isDot()) {
38 self::next();
40 if (self::isFile()) {
41 if (self::isReadable()) {
42 $this->commands[] = self::getFilename();
45 self::next();
48 //fetch directory $path and return the filename as command.
51 public function set_cmessage($message){
52 $this->message = $message;
55 protected function setCommands($path = '') {
56 if (!empty($path)) {
57 $this->_commandsPath = $path;