2008-05-09 11:16:04 +09:00
|
|
|
<?php
|
2008-05-21 04:14:12 +09:00
|
|
|
/*
|
2008-05-15 04:26:48 +09:00
|
|
|
* Laconica - a distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
2008-05-21 04:14:12 +09:00
|
|
|
*
|
2008-05-15 04:26:48 +09:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2008-05-21 04:14:12 +09:00
|
|
|
*
|
2008-05-15 04:26:48 +09:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2008-05-21 04:14:12 +09:00
|
|
|
*
|
2008-05-15 04:26:48 +09:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2008-05-09 11:16:04 +09:00
|
|
|
|
2008-05-18 00:47:01 +09:00
|
|
|
if (!defined('LACONICA')) { exit(1); }
|
2008-05-15 04:00:09 +09:00
|
|
|
|
2008-05-09 11:16:04 +09:00
|
|
|
class Action { // lawsuit
|
|
|
|
|
|
|
|
var $args;
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2008-05-09 11:16:04 +09:00
|
|
|
function Action() {
|
|
|
|
}
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2008-05-09 11:16:04 +09:00
|
|
|
function arg($key) {
|
2008-05-18 01:42:18 +09:00
|
|
|
if (array_key_exists($key, $this->args)) {
|
2008-05-09 11:16:04 +09:00
|
|
|
return $this->args[$key];
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2008-05-21 20:27:07 +09:00
|
|
|
function trimmed($key) {
|
|
|
|
$arg = $this->arg($key);
|
|
|
|
return (is_string($arg)) ? trim($arg) : $arg;
|
|
|
|
}
|
|
|
|
|
2008-05-18 01:37:49 +09:00
|
|
|
function handle($argarray) {
|
2008-05-22 19:36:30 +09:00
|
|
|
$strip = get_magic_quotes_gpc();
|
2008-05-18 01:23:05 +09:00
|
|
|
$this->args = array();
|
2008-05-18 01:37:49 +09:00
|
|
|
foreach ($argarray as $k => $v) {
|
2008-05-22 19:36:30 +09:00
|
|
|
$this->args[$k] = ($strip) ? stripslashes($v) : $v;
|
2008-05-18 01:23:05 +09:00
|
|
|
}
|
2008-05-09 11:16:04 +09:00
|
|
|
}
|
2008-05-22 20:29:54 +09:00
|
|
|
|
|
|
|
function boolean($key, $def=false) {
|
|
|
|
$arg = $this->arg($key);
|
|
|
|
return (is_null($arg)) ? $def :
|
2008-05-30 00:16:02 +09:00
|
|
|
(strcasecmp($arg, 'true') == 0) ? true :
|
|
|
|
(strcasecmp($arg, 'yes') == 0) ? true :
|
|
|
|
(strcasecmp($arg, '1') == 0) ? true :
|
|
|
|
(strcasecmp($arg, 'false') == 0) ? false :
|
|
|
|
(strcasecmp($arg, 'no') == 0) ? false :
|
|
|
|
(strcasecmp($arg, '0') == 0) ? false :
|
2008-05-22 20:29:54 +09:00
|
|
|
$def;
|
|
|
|
}
|
2008-05-09 11:16:04 +09:00
|
|
|
}
|