From 0048f6399038e1186f8d8010be88cdf974e92c27 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Wed, 19 Jun 2019 12:03:26 +0200 Subject: [PATCH] Started to work on frontend code --- src/site/clubs.php | 3 +- src/site/helpers/part/textarea.php | 18 +++++++ src/site/helpers/part/textfield.php | 18 +++++++ src/site/helpers/parts.php | 59 +++++++++++++++++++++++ src/site/parts/user/name.php | 21 ++++++++ src/site/views/part/view.html.php | 74 +++++++++++++++++++++++++++++ 6 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 src/site/helpers/part/textarea.php create mode 100644 src/site/helpers/part/textfield.php create mode 100644 src/site/helpers/parts.php create mode 100644 src/site/parts/user/name.php create mode 100644 src/site/views/part/view.html.php diff --git a/src/site/clubs.php b/src/site/clubs.php index 27103ab..331d935 100644 --- a/src/site/clubs.php +++ b/src/site/clubs.php @@ -8,7 +8,8 @@ defined('_JEXEC') or die; JLoader::discover('Clubs', JPATH_ROOT . '/administrator/components/com_clubs/mymodels'); -JLoader::register("ClubsHelperAuth", JPATH_ROOT . "/components/com_clubs/helpers/auth.php"); +JLoader::registerPrefix('ClubsHelper', JPATH_ROOT . '/components/com_clubs/helpers'); +JLoader::registerPrefix('ClubsPart', JPATH_ROOT . '/components/com_clubs/parts'); JLoader::registerPrefix('AbstractClubs', JPATH_ROOT . '/administrator/components/com_clubs/abstract'); diff --git a/src/site/helpers/part/textarea.php b/src/site/helpers/part/textarea.php new file mode 100644 index 0000000..8922790 --- /dev/null +++ b/src/site/helpers/part/textarea.php @@ -0,0 +1,18 @@ +'; + $ret .= $this->getEditContent(); + $ret .= ''; + + return $ret; + } + +} diff --git a/src/site/helpers/part/textfield.php b/src/site/helpers/part/textfield.php new file mode 100644 index 0000000..c360b00 --- /dev/null +++ b/src/site/helpers/part/textfield.php @@ -0,0 +1,18 @@ +getEditContent(); + $ret .= '">'; + + return $ret; + } + +} diff --git a/src/site/helpers/parts.php b/src/site/helpers/parts.php new file mode 100644 index 0000000..a66ba4c --- /dev/null +++ b/src/site/helpers/parts.php @@ -0,0 +1,59 @@ +getPartName(); + + $ret = "
"; + $ret .= ""; + $ret .= $this->getEditMarkup(); + $ret .= '  '; + $ret .= ''; + $ret .= '
'; + + return $ret; + } + + abstract protected function getEditMarkup(); + + /** + * @return string + */ + abstract protected function getEditContent(); + + /** + * @return string + */ + protected function getViewContent() + { + return $this->getEditContent(); + } + + /** + * @return string + */ + public function getViewPart() + { + $ret = ''; + + $ret = ""; + + return $ret; + } +} diff --git a/src/site/parts/user/name.php b/src/site/parts/user/name.php new file mode 100644 index 0000000..cc30818 --- /dev/null +++ b/src/site/parts/user/name.php @@ -0,0 +1,21 @@ +getCurrentUser(); + + return htmlentities($user->getName()); + } + +} diff --git a/src/site/views/part/view.html.php b/src/site/views/part/view.html.php new file mode 100644 index 0000000..4831619 --- /dev/null +++ b/src/site/views/part/view.html.php @@ -0,0 +1,74 @@ +me = $auth->getCurrentUser(); + +// $this->clubsPresident = $this->me->getPresidentClubs(); +// $this->positions = $this->me->getPositions(); + +// HTMLHelper::_('jquery.framework'); +// Factory::getDocument()->addScript(Uri::base(true) . "components/com_clubs/js/edit.js"); +// parent::display($tpl); + + $app = Factory::getApplication(); + $input = $app->input; + + $mode = $input->get->getCmd('mode', 'view'); + $type = $input->get->getCmd('type'); + + $parthandler = $this->getPart($type); + + if($mode === 'view') + $this->view($parthandler); + else + $this->edit($parthandler); + + jexit(); + } + + /** + * @param ClubsHelperParts $parthandler + */ + private function view($parthandler) + { + echo $parthandler->getViewPart(); + } + + /** + * @param ClubsHelperParts $parthandler + */ + private function edit($parthandler) + { + echo $parthandler->getEditPart(); + } + + private function getPart($type) + { + if(! preg_match('/.*\..*/', $type)) + throw new Exception(); + + list($obj, $fcn) = explode('.', $type, 2); + switch($obj) + { + case 'user': + switch($fcn) + { + case 'name': + return new ClubsPartUserName(); + } + } + } +}