Removed minor bug and implemented stub of first class

This commit is contained in:
Christian Wolf 2019-05-22 14:22:45 +02:00
parent cb6068bfd6
commit b3e28d7884
6 changed files with 65 additions and 5 deletions

View File

@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<buildpath> <buildpath>
<buildpathentry kind="src" path="src"/> <buildpathentry kind="src" path="src"/>
<buildpathentry external="true" kind="lib" path="/home/private/slt/joomla"/> <buildpathentry external="true" kind="lib" path="/home/private/slt/joomla">
<accessrules>
<accessrule kind="nonaccessible" pattern="administrator/components/com_clubs"/>
</accessrules>
</buildpathentry>
<buildpathentry external="true" kind="lib" path="/srv/slt-dev"/> <buildpathentry external="true" kind="lib" path="/srv/slt-dev"/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/> <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath> </buildpath>

View File

@ -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('AbstractClubs', JPATH_ROOT . '/administrator/components/com_clubs/abstract');
JLoader::registerPrefix('AbstractCommonClubs', JPATH_ROOT . '/administrator/components/com_clubs/common/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('ClubsHelper', JPATH_ROOT . '/administrator/components/com_clubs/common/helper');
JLoader::registerPrefix('CommonClubsModel', JPATH_ROOT . '/administrator/components/com_clubs/common/models');
$controller = BaseController::getInstance("Clubs"); $controller = BaseController::getInstance("Clubs");
$input = Factory::getApplication()->input; $input = Factory::getApplication()->input;

View File

@ -94,7 +94,8 @@ abstract class AbstractCommonClubsModel
foreach($attribs as $k => $v) 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->from($factory->getTableName());
$q->where("id = {$this->id}"); $q->where("id = {$this->id}");
@ -253,7 +254,11 @@ abstract class AbstractCommonClubsModel
{ {
$q->insert($factory->getTableName()); $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)); $q->columns($q->qn($dbcols));
@ -282,7 +287,9 @@ abstract class AbstractCommonClubsModel
{ {
$q->update($factory->getTableName()); $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); $quotedData = $this->getQuotedData($attribs, $q);

View File

@ -22,7 +22,7 @@ abstract class AbstractCommonClubsModelFactory
* ) * )
* *
* The inner arrays contain the following entries: * 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. * - type: The type of the column. If nothing is specified, string is assumed.
* - string * - string
* - int * - int

View File

@ -0,0 +1,14 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelClub extends AbstractCommonClubsModel
{
protected function getFactory()
{
return new CommonClubsModelFactoryClub();
}
}

View File

@ -0,0 +1,34 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class CommonClubsModelFactoryClub extends AbstractCommonClubsModelFactory
{
public function getAttributes()
{
return array(
'name'=>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';
}
}