littlepaul hat geschrieben:
Armin, das hattest du aber heute Nachmittag gar nicht erwähnt. 8)
Hatte ich auch gar nicht vor. Aber der Quelltext ist nicht gerade das, was ich gerne pflegen würde.
Als erstes eine neue Klammerstellung:
class foobar
{
function foobar() {}
function do_foo($foo)
{
if ($foo > 100) {
return 'foobar';
}
else {
return false;
}
}
function switch_foo($foo)
{
switch ($foo)
{
case 1:
case 2:
case 3:
case 4: return false;
case 5: return 'foobar';
}
}
}
Damit wird der Quelltext überschaubarer.
Und Daten, die vom Dateisystem kommen, werden jetzt in Objekten zurückgeworfen:
class attachment_info_object
{
var $id;
var $mime_type;
var $time_created;
var $username_created;
var $userip_created;
var $time_edited;
var $username_edited;
var $userip_edited;
var $size;
var $notes;
var $linked_page;
function attachment_info_object($id)
{
$this->$id = $id;
$this->$mime_type = 'text/plain';
$this->$time_created = 0;
$this->$time_edited = 0;
$this->$username_created = '';
$this->$username_edited = '';
$this->$userip_created = '0.0.0.0';
$this->$userip_edited = '0.0.0.0';
$this->$size = -1;
$this->$notes = '';
$this->$linked_page = 'attachment:'.$id;
}
function ~attachment_info_object() {}
function set_id($id) { $this->$id = $id; }
function get_id() { return $this->$id; }
function set_mime_type($mime_type) { $this->$mime_type = $mime_type; }
function get_mime_type() { return $this->$mime_type; }
function set_time_created($time_created) { $this->$time_created = $time_created; }
function get_time_created() { return $this->$time_created; }
function set_username_created($username_created) { $this->$username_created = $username_created; }
function get_username_created() { return $this->$username_created; }
function set_userid_created($userip_created) { $this->$userip_created = $userip_created; }
function get_userid_created() { return $this->$userip_created; }
function set_time_edited($time_edited) { $this->$time_edited = $time_edited; }
function get_time_edited() { return $this->$time_edited; }
function set_username_edited($username_edited) { $this->$username_edited = $username_edited; }
function get_username_edited() { return $this->$username_edited; }
function set_userid_edited($userip_edited) { $this->$userip_edited = $userip_edited; }
function get_userid_edited() { return $this->$userip_edited; }
function set_size($size) { $this->$size = $size; }
function get_size() { return $this->$size; }
function set_notes($notes) { $this->$notes = $notes; }
function get_notes() { return $this->$notes; }
function set_linked_page($linked_page) { $this->$linked_page = $linked_page; }
function get_linked_page() { return $this->$linked_page; }
}
Dann kann der Programmierer eines Dateisystems diese Objekte für seine Zwecke erweitern.
Solange sich die Basisfunktionen nicht unterscheiden.