diff --git a/src/admin/abstract/view/list.php b/src/admin/abstract/view/list.php
new file mode 100644
index 0000000..d794306
--- /dev/null
+++ b/src/admin/abstract/view/list.php
@@ -0,0 +1,67 @@
+prepared = TRUE;
+
+ $this->objects = $this->loadObjects();
+ $baseUrl = "index.php?option=com_clubs";
+ $viewName = $this->getSingleViewName();
+ $controllerName = $this->getControllerName();
+
+ $this->addUrl = Route::_("$baseUrl&view=$viewName&id=new");
+ $this->changeUrl = Route::_("$baseUrl&view=$viewName&id=__ID__");
+ $this->delUrl = Route::_("$baseUrl&task=$controllerName.delete&id=__ID__");
+ }
+
+ public function display($tpl = null)
+ {
+ if(!$this->prepared)
+ $this->prepareDisplay();
+
+ parent::display($tpl);
+ }
+
+ protected abstract function getSingleBaseName();
+
+ protected function getControllerName()
+ {
+ return $this->getSingleBaseName();
+ }
+
+ protected function getSingleViewName()
+ {
+ return $this->getSingleBaseName();
+ }
+
+ /**
+ * @return AbstractCommonClubsModelFactory
+ */
+ protected abstract function getFactory();
+
+ protected function loadObjects()
+ {
+ $factory = $this->getFactory();
+ return $factory->loadElements();
+ }
+
+}
diff --git a/src/admin/abstract/view/single.php b/src/admin/abstract/view/single.php
index 70d1a6a..8afa862 100644
--- a/src/admin/abstract/view/single.php
+++ b/src/admin/abstract/view/single.php
@@ -11,6 +11,9 @@ abstract class AbstractClubsViewSingle extends HtmlView
{
protected $address;
+ /**
+ * @var AbstractCommonClubsModel
+ */
protected $object;
protected $isNew;
@@ -23,32 +26,28 @@ abstract class AbstractClubsViewSingle extends HtmlView
$input = Factory::getApplication()->input;
$id = $input->get->get('id');
- $modelClass = 'Clubs' . $this->getModelName();
+ $controllerName = $this->getControllerName();
- $controller = $this->getControllerName();
if($id === 'new')
{
- $this->address = Route::_("index.php?option=com_clubs&task={$controller}.new");
- $this->object = call_user_func(array($modelClass, 'create' . $this->getModelName()));
+ $this->address = Route::_("index.php?option=com_clubs&task={$controllerName}.new");
+ $this->object = $this->createNewObject();
$this->isNew = true;
}
else if(is_numeric($id))
{
- $this->address = Route::_("index.php?option=com_clubs&task={$controller}.change");
- $this->object = call_user_func(array($modelClass, 'load' . $this->getModelName()), (int) $id);
+ $id = (int) $id;
+ $this->address = Route::_("index.php?option=com_clubs&task={$controllerName}.change&id=$id");
+ $this->object = $this->loadObject($id);
$this->isNew = false;
}
else
- throw new Exception('Need an object id.');
-
- if($input->get->get('data', null, 'json') != null)
+ throw new Exception('Need a valid object id.');
+
+ $jsonData = $input->get->get('data', null, 'json');
+ if($jsonData !== null)
{
- // Restore previous data
- $dataurl = $input->get->get('data', null, 'json');
- $data = json_decode($dataurl, true);
-
- $controller = $this->getElementController();
- $controller->applyData($this->object, $data);
+ $this->object->unpack($jsonData);
}
}
@@ -61,26 +60,45 @@ abstract class AbstractClubsViewSingle extends HtmlView
parent::display($tpl);
}
- protected abstract function getViewName();
+// protected abstract function getViewName();
- protected function getControllerName()
+ protected abstract function getControllerName();
+
+// protected function getModelName()
+// {
+// $name = $this->getViewName();
+// return $this->capitalize($name);
+// }
+
+// protected function getModelClass()
+// {
+// return 'Clubs' . $this->getModelName();
+// }
+
+// private function capitalize($s)
+// {
+// $first = substr($s, 0, 1);
+// $rest = substr($s, 1);
+// return strtoupper($first) . $rest;
+// }
+
+// protected abstract function getElementController();
+
+ /**
+ * @return AbstractCommonClubsModelFactory
+ */
+ protected abstract function getFactory();
+
+ protected function createNewObject()
{
- return $this->getViewName();
+ $factory = $this->getFactory();
+ return $factory->createNew();
}
- protected function getModelName()
+ protected function loadObject($id)
{
- $name = $this->getViewName();
- return $this->capitalize($name);
+ $factory = $this->getFactory();
+ return $factory->loadById($id);
}
- private function capitalize($s)
- {
- $first = substr($s, 0, 1);
- $rest = substr($s, 1);
- return strtoupper($first) . $rest;
- }
-
- protected abstract function getElementController();
-
}
diff --git a/src/admin/common/abstract/model.php b/src/admin/common/abstract/model.php
index 90babdc..65b4fac 100644
--- a/src/admin/common/abstract/model.php
+++ b/src/admin/common/abstract/model.php
@@ -327,12 +327,15 @@ abstract class AbstractCommonClubsModel
$vals = $this->filterPackData($vals);
$json = json_encode($vals);
- return urldecode($json);
+ return urlencode($json);
}
- public function unpack($str)
+ public function unpack($str, $decode = false)
{
- $json = urlencode($str);
+ if($decode)
+ $json = urldecode($str);
+ else
+ $json = $str;
$data = json_decode($json, true);
$vals = $this->unpackExternalReferencesFromKeys($data);
diff --git a/src/admin/views/offers/tmpl/default.php b/src/admin/views/offers/tmpl/default.php
index 433af8d..470fbd5 100644
--- a/src/admin/views/offers/tmpl/default.php
+++ b/src/admin/views/offers/tmpl/default.php
@@ -11,18 +11,18 @@ defined('_JEXEC') or die;
-offers as $offer): ?>
+objects as $offer): ?>
getId()); ?>
Bezeichnung
- Löschen?
+
id