openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 5a35ecc82171bf7872e789fcdd1f0040f9aa90a7
parent 15ff8bf82a2c86b322898162131d14068d5b0b07
Author: dankert <devnull@localhost>
Date:   Wed, 16 Dec 2009 16:56:17 +0100

Refactoring: Neue Methoden countObjects() und size().

Diffstat:
objectClasses/Project.class.php | 40++++++++++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/objectClasses/Project.class.php b/objectClasses/Project.class.php @@ -723,23 +723,34 @@ EOF $db_dest->commit(); } + - - + /** - * Liefert alle verf?gbaren Projekt-Ids + * Ermittelt die Anzahl aller Objekte in diesem Projekt. + * @return int Anzahl */ - function info() + function countObjects() { - $info = array(); - $db = db_connection(); $sql = new Sql( 'SELECT COUNT(*) FROM {t_object} '. ' WHERE projectid = {projectid}' ); $sql->setInt( 'projectid', $this->projectid ); - $info['count_objects'] = $db->getOne( $sql ); + return $db->getOne( $sql ); + + } + + + /** + * Ermittelt die Größe aller Dateien in diesem Projekt. + * @return int Summe aller Dateigroessen + */ + function size() + { + $db = db_connection(); + $sql = new Sql( <<<SQL SELECT SUM(size) FROM {t_file} LEFT JOIN {t_object} @@ -749,7 +760,20 @@ SQL ); $sql->setInt( 'projectid', $this->projectid ); - $info['sum_filesize'] = number_format($db->getOne( $sql )/1000).' kB'; + return $db->getOne( $sql ); + } + + + + /** + * Liefert alle verf?gbaren Projekt-Ids + */ + function info() + { + $info = array(); + + $info['count_objects'] = $this->countObjects(); + $info['sum_filesize' ] = $this->size(); return $info;