Registered user parts (only view)

This commit is contained in:
Christian Wolf 2019-06-19 13:27:22 +02:00
parent 5743219a1c
commit e89aac01a3
12 changed files with 191 additions and 66 deletions

View File

@ -6,9 +6,18 @@ defined('_JEXEC') or die;
abstract class ClubsHelperPartTextarea extends ClubsHelperParts
{
public function getEditMarkup()
protected function additionalParams()
{
$ret = '<textarea name="value">';
return null;
}
protected function getEditMarkup()
{
$ret = '<textarea name="value"';
$additional = $this->additionalParams();
if($additional !== null)
$ret .= " $additional";
$ret .= '>';
$ret .= $this->getEditContent();
$ret .= '</textarea>';

View File

@ -6,7 +6,7 @@ defined('_JEXEC') or die;
abstract class ClubsHelperPartTextfield extends ClubsHelperParts
{
public function getEditMarkup()
protected function getEditMarkup()
{
$ret = '<input type="text" name="value" value="';
$ret .= $this->getEditContent();

View File

@ -40,7 +40,13 @@ abstract class ClubsHelperParts
*/
protected function getViewContent()
{
return $this->getEditContent();
$content = $this->getEditContent();
if(empty($content))
{
return '<i>Kein Wert wurde vergeben</i>';
}
else
return $content;
}
/**

View File

@ -0,0 +1,31 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPartUserAddress extends ClubsHelperPartTextarea
{
protected function getPartName()
{
return 'user.address';
}
protected function getEditContent()
{
$auth = new ClubsHelperAuth();
$user = $auth->getCurrentUser();
return htmlentities($user->getAddress());
}
protected function getViewContent()
{
return nl2br(parent::getViewContent());
}
protected function additionalParams()
{
return 'rows="4"';
}
}

View File

@ -0,0 +1,21 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPartUserCity extends ClubsHelperPartTextfield
{
protected function getPartName()
{
return 'user.city';
}
protected function getEditContent()
{
$auth = new ClubsHelperAuth();
$user = $auth->getCurrentUser();
return htmlentities($user->getCity());
}
}

View File

@ -0,0 +1,21 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPartUserMail extends ClubsHelperPartTextfield
{
protected function getPartName()
{
return 'user.mail';
}
protected function getEditContent()
{
$auth = new ClubsHelperAuth();
$user = $auth->getCurrentUser();
return htmlentities($user->getMail());
}
}

View File

@ -0,0 +1,21 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPartUserMobile extends ClubsHelperPartTextfield
{
protected function getPartName()
{
return 'user.mobile';
}
protected function getEditContent()
{
$auth = new ClubsHelperAuth();
$user = $auth->getCurrentUser();
return htmlentities($user->getMobile());
}
}

View File

@ -0,0 +1,21 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPartUserPhone extends ClubsHelperPartTextfield
{
protected function getPartName()
{
return 'user.phone';
}
protected function getEditContent()
{
$auth = new ClubsHelperAuth();
$user = $auth->getCurrentUser();
return htmlentities($user->getPhone());
}
}

View File

@ -0,0 +1,21 @@
<?php
// No direct access.
defined('_JEXEC') or die;
class ClubsPartUserUsername extends ClubsHelperPartTextfield
{
protected function getPartName()
{
return 'user.username';
}
protected function getEditContent()
{
$auth = new ClubsHelperAuth();
$user = $auth->getCurrentUser();
return htmlentities($user->getUsername());
}
}

View File

@ -23,48 +23,60 @@ defined('_JEXEC') or die;
<div class='clubs_row'>
<div class='clubs_title_row'>Benutzer-Alias</div>
<div class='clubs_content_row'>
<?php echo htmlentities($this->me->getUsername()); ?>
<span class='icon-apply clubs-hidden edit-icon' style='font-size: 200%; margin-left: 0.75em;'></span>
<?php
$partHandler = new ClubsPartUserUsername();
echo $partHandler->getViewPart();
?>
</div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Adresse</div>
<div class='clubs_content_row address-field'>
<?php echo nl2br(htmlentities($this->me->getAddress())); ?>
<span class='icon-apply clubs-hidden edit-icon' style='font-size: 200%; margin-left: 0.75em;'></span>
<?php
$partHandler = new ClubsPartUserAddress();
echo $partHandler->getViewPart();
?>
</div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Stadt</div>
<div class='clubs_content_row'>
<?php echo htmlentities($this->me->getCity()); ?>
<span class='icon-apply clubs-hidden edit-icon' style='font-size: 200%; margin-left: 0.75em;'></span>
<?php
$partHandler = new ClubsPartUserCity();
echo $partHandler->getViewPart();
?>
</div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>E-Mail-Adresse</div>
<div class='clubs_content_row'>
<?php echo htmlentities($this->me->getMail()); ?>
<span class='icon-apply clubs-hidden edit-icon' style='font-size: 200%; margin-left: 0.75em;'></span>
<?php
$partHandler = new ClubsPartUserMail();
echo $partHandler->getViewPart();
?>
</div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Telefon-Nr.</div>
<div class='clubs_content_row'>
<?php echo $this->me->getPhone() !== null ? htmlentities($this->me->getPhone()) : '<i>nicht angegeben</i>'; ?>
<span class='icon-apply clubs-hidden edit-icon' style='font-size: 200%; margin-left: 0.75em;'></span>
<?php
$partHandler = new ClubsPartUserPhone();
echo $partHandler->getViewPart();
?>
</div>
</div>
<div class='clubs_row'>
<div class='clubs_title_row'>Handy-Nr.</div>
<div class='clubs_content_row'>
<?php echo $this->me->getMobile() !== null ? htmlentities($this->me->getMobile()) : '<i>nicht angegeben</i>'; ?>
<span class='icon-apply clubs-hidden edit-icon' style='font-size: 200%; margin-left: 0.75em;'></span>
<?php
$partHandler = new ClubsPartUserMobile();
echo $partHandler->getViewPart();
?>
</div>
</div>

View File

@ -1,50 +0,0 @@
<?php
use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
$input = Factory::getApplication()->input;
$type = $input->get->getCmd('type');
$mode = $input->get->getCmd('mode', 'view');
$auth = new ClubsHelperAuth();
$user = $auth->getCurrentUser();
if($mode === 'edit')
{
echo "<form method='POST' action='index.php?option=com_clubs&task=parts.edit&format=json' class='clubs-part'>";
switch($type)
{
case 'name':
$partname = 'user.name';
$value = $user->getName();
$value = htmlentities($value);
$content = "<input name='name' value='$value'>";
break;
}
echo "<input type='hidden' name='partname' value='$partname'>";
echo $content;
echo '&nbsp;<a class="clubs-save" href="#"><span class="icon-ok"></span></a>&nbsp;';
echo '<a class="clubs-abort" href="index.php?option=com_clubs&view=mypage&layout=parts&type='.$type.'"><span class="icon-cancel-2"></span></a>';
echo '</form>';
}
elseif ($mode === 'view')
{
switch ($type)
{
case 'name':
$content = htmlentities($user->getName());
$partname = 'name';
break;
}
echo "<a class='clubs-edit' href='index.php?option=com_clubs&view=mypage&layout=parts&mode=edit&type=$partname'>";
echo $content;
echo "<span class='icon-apply clubs-hidden edit-icon' style='font-size: 200%; margin-left: 0.75em;'></span></a>";
}
jexit();

View File

@ -58,6 +58,18 @@ class ClubsViewPart extends HtmlView
{
case 'name':
return new ClubsPartUserName();
case 'username':
return new ClubsPartUserUsername();
case 'address':
return new ClubsPartUserAddress();
case 'city':
return new ClubsPartUserCity();
case 'mail':
return new ClubsPartUserMail();
case 'phone':
return new ClubsPartUserPhone();
case 'mobile':
return new ClubsPartUserMobile();
}
}
}