diff --git a/.buildpath b/.buildpath index a59af60..635eec4 100644 --- a/.buildpath +++ b/.buildpath @@ -1,7 +1,11 @@ - + + + + + diff --git a/src/admin/clubs.php b/src/admin/clubs.php index c82b2d7..f1320ba 100644 --- a/src/admin/clubs.php +++ b/src/admin/clubs.php @@ -10,6 +10,7 @@ JLoader::discover('Clubs', JPATH_ROOT . '/administrator/components/com_clubs/mym JLoader::registerPrefix('AbstractClubs', JPATH_ROOT . '/administrator/components/com_clubs/abstract'); JLoader::registerPrefix('AbstractCommonClubs', JPATH_ROOT . '/administrator/components/com_clubs/common/abstract'); // JLoader::registerPrefix('ClubsHelper', JPATH_ROOT . '/administrator/components/com_clubs/common/helper'); +JLoader::registerPrefix('CommonClubsModel', JPATH_ROOT . '/administrator/components/com_clubs/common/models'); $controller = BaseController::getInstance("Clubs"); $input = Factory::getApplication()->input; diff --git a/src/admin/common/abstract/model.php b/src/admin/common/abstract/model.php index e77a31d..b87f6fa 100644 --- a/src/admin/common/abstract/model.php +++ b/src/admin/common/abstract/model.php @@ -94,7 +94,8 @@ abstract class AbstractCommonClubsModel foreach($attribs as $k => $v) { - $q->select($q->qn($v['col'], $k)); + $rawColName = isset($v['col']) ? $v['col'] : $k; + $q->select($q->qn($rawColName, $k)); } $q->from($factory->getTableName()); $q->where("id = {$this->id}"); @@ -253,7 +254,11 @@ abstract class AbstractCommonClubsModel { $q->insert($factory->getTableName()); - $dbcols = array_map(function ($v){return $v['col'];}, $attribs); + $dbcols = array(); + foreach($attribs as $k => $v) + { + $dbcols[] = isset($v['col']) ? $v['col'] : $k; + } $q->columns($q->qn($dbcols)); @@ -282,7 +287,9 @@ abstract class AbstractCommonClubsModel { $q->update($factory->getTableName()); - $dbcols = array_map(function ($v){return $v['col'];}, $attribs); + $dbcols = array(); + foreach($attribs as $k => $v) + $dbcols[] = isset($v['col']) ? $v['col'] : $k; $quotedData = $this->getQuotedData($attribs, $q); diff --git a/src/admin/common/abstract/modelfactory.php b/src/admin/common/abstract/modelfactory.php index ebb3169..ac3ce15 100644 --- a/src/admin/common/abstract/modelfactory.php +++ b/src/admin/common/abstract/modelfactory.php @@ -22,7 +22,7 @@ abstract class AbstractCommonClubsModelFactory * ) * * The inner arrays contain the following entries: - * - col: The name of the column in the database. Mandatory. + * - col: The name of the column in the database. Defaults to the key name * - type: The type of the column. If nothing is specified, string is assumed. * - string * - int diff --git a/src/admin/common/models/club.php b/src/admin/common/models/club.php new file mode 100644 index 0000000..12ed40a --- /dev/null +++ b/src/admin/common/models/club.php @@ -0,0 +1,14 @@ +array(), + 'address'=>array(), + 'city'=>array(), + 'homepage'=>array(), + 'mail'=>array(), + 'iban'=>array(), + 'bic'=>array(), + 'charitable'=>array('type'=>'int'), + 'president'=>array('type'=>'int', 'ref'=>'CommonClubsModelUser') + ); + } + + public function getTableName() + { + return '#__club_clubs'; + } + + public function getClassName() + { + return 'CommonClubsModelClub'; + } + + +} \ No newline at end of file