Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Simplify the member_ templates and support dynamic front end groups
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed May 19, 2014
1 parent 4d46486 commit acb854e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 254 deletions.
39 changes: 16 additions & 23 deletions system/modules/core/modules/ModulePersonalData.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ protected function compile()
$hasUpload = false;
$row = 0;

// Predefine the group order (other groups will be appended automatically)
$arrGroups = array
(
'personal' => array(),
'address' => array(),
'contact' => array(),
'login' => array(),
'profile' => array()
);

$blnModified = false;
$objMember = \MemberModel::findByPk($this->User->id);

Expand Down Expand Up @@ -356,37 +366,20 @@ protected function compile()
$this->Template->contactDetails = $GLOBALS['TL_LANG']['tl_member']['contactDetails'];
$this->Template->personalData = $GLOBALS['TL_LANG']['tl_member']['personalData'];

// Add groups
// Add the groups
foreach ($arrFields as $k=>$v)
{
$this->Template->$k = $v;
$this->Template->$k = $v; // backwards compatibility

$key = $k . (($k == 'personal') ? 'Data' : 'Details');
$arrGroups[$GLOBALS['TL_LANG']['tl_member'][$key]] = $v;
}

$this->Template->categories = $arrGroups;
$this->Template->formId = 'tl_member_' . $this->id;
$this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['saveData']);
$this->Template->action = \Environment::get('indexFreeRequest');
$this->Template->enctype = $hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
$this->Template->rowLast = 'row_' . $row . ((($row % 2) == 0) ? ' even' : ' odd');

// HOOK: add memberlist fields
if (in_array('memberlist', \ModuleLoader::getActive()))
{
$this->Template->profile = $arrFields['profile'];
$this->Template->profileDetails = $GLOBALS['TL_LANG']['tl_member']['profileDetails'];
}

// HOOK: add newsletter fields
if (in_array('newsletter', \ModuleLoader::getActive()))
{
$this->Template->newsletter = $arrFields['newsletter'];
$this->Template->newsletterDetails = $GLOBALS['TL_LANG']['tl_member']['newsletterDetails'];
}

// HOOK: add helpdesk fields
if (in_array('helpdesk', \ModuleLoader::getActive()))
{
$this->Template->helpdesk = $arrFields['helpdesk'];
$this->Template->helpdeskDetails = $GLOBALS['TL_LANG']['tl_member']['helpdeskDetails'];
}
}
}
43 changes: 18 additions & 25 deletions system/modules/core/modules/ModuleRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ protected function compile()
$objCaptcha = null;
$doNotSubmit = false;

// Predefine the group order (other groups will be appended automatically)
$arrGroups = array
(
'personal' => array(),
'address' => array(),
'contact' => array(),
'login' => array(),
'profile' => array()
);

// Captcha
if (!$this->disableCaptcha)
{
Expand Down Expand Up @@ -281,7 +291,7 @@ protected function compile()
$strCaptcha = $objCaptcha->parse();

$this->Template->fields .= $strCaptcha;
$arrFields['captcha'] .= $strCaptcha;
$arrFields['captcha']['captcha'] .= $strCaptcha;
}

$this->Template->rowLast = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
Expand All @@ -300,37 +310,20 @@ protected function compile()
$this->Template->personalData = $GLOBALS['TL_LANG']['tl_member']['personalData'];
$this->Template->captchaDetails = $GLOBALS['TL_LANG']['MSC']['securityQuestion'];

// Add groups
// Add the groups
foreach ($arrFields as $k=>$v)
{
$this->Template->$k = $v;
$this->Template->$k = $v; // backwards compatibility

$key = $k . (($k == 'personal') ? 'Data' : 'Details');
$arrGroups[$GLOBALS['TL_LANG']['tl_member'][$key]] = $v;
}

$this->Template->captcha = $arrFields['captcha'];
$this->Template->categories = $arrGroups;
$this->Template->formId = 'tl_registration';
$this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['register']);
$this->Template->action = \Environment::get('indexFreeRequest');

// HOOK: add memberlist fields
if (in_array('memberlist', \ModuleLoader::getActive()))
{
$this->Template->profile = $arrFields['profile'];
$this->Template->profileDetails = $GLOBALS['TL_LANG']['tl_member']['profileDetails'];
}

// HOOK: add newsletter fields
if (in_array('newsletter', \ModuleLoader::getActive()))
{
$this->Template->newsletter = $arrFields['newsletter'];
$this->Template->newsletterDetails = $GLOBALS['TL_LANG']['tl_member']['newsletterDetails'];
}

// HOOK: add helpdesk fields
if (in_array('helpdesk', \ModuleLoader::getActive()))
{
$this->Template->helpdesk = $arrFields['helpdesk'];
$this->Template->helpdeskDetails = $GLOBALS['TL_LANG']['tl_member']['helpdeskDetails'];
}
$this->Template->captcha = $arrFields['captcha']['captcha']; // backwards compatibility
}


Expand Down
117 changes: 14 additions & 103 deletions system/modules/core/templates/member/member_grouped.html5
Original file line number Diff line number Diff line change
Expand Up @@ -11,109 +11,20 @@
<input type="hidden" name="FORM_SUBMIT" value="<?php echo $this->formId; ?>">
<input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}">

<?php if ($this->personal): ?>
<fieldset>
<legend><?php echo $this->personalData; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->personal); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->address): ?>
<fieldset>
<legend><?php echo $this->addressDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->address); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->contact): ?>
<fieldset>
<legend><?php echo $this->contactDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->contact); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->login): ?>
<fieldset>
<legend><?php echo $this->loginDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->login); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->profile): ?>
<fieldset>
<legend><?php echo $this->profileDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->profile); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->newsletter): ?>
<fieldset>
<legend><?php echo $this->newsletterDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->newsletter); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->helpdesk): ?>
<fieldset>
<legend><?php echo $this->helpdeskDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->helpdesk); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->captcha): ?>
<fieldset>
<legend><?php echo $this->captchaDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo $this->captcha; ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>
<?php foreach ($this->categories as $legend=>$category): ?>
<?php if (!empty($category)): ?>
<fieldset>
<legend><?php echo $legend; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $category); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>
<?php endforeach; ?>

<div class="submit_container">
<input type="submit" class="submit" value="<?php echo $this->slabel; ?>">
Expand Down
117 changes: 14 additions & 103 deletions system/modules/core/templates/member/member_grouped.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,109 +11,20 @@
<input type="hidden" name="FORM_SUBMIT" value="<?php echo $this->formId; ?>" />
<input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}" />

<?php if ($this->personal): ?>
<fieldset>
<legend><?php echo $this->personalData; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->personal); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->address): ?>
<fieldset>
<legend><?php echo $this->addressDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->address); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->contact): ?>
<fieldset>
<legend><?php echo $this->contactDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->contact); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->login): ?>
<fieldset>
<legend><?php echo $this->loginDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->login); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->profile): ?>
<fieldset>
<legend><?php echo $this->profileDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->profile); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->newsletter): ?>
<fieldset>
<legend><?php echo $this->newsletterDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->newsletter); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->helpdesk): ?>
<fieldset>
<legend><?php echo $this->helpdeskDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $this->helpdesk); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>

<?php if ($this->captcha): ?>
<fieldset>
<legend><?php echo $this->captchaDetails; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo $this->captcha; ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>
<?php foreach ($this->categories as $legend=>$category): ?>
<?php if (!empty($category)): ?>
<fieldset>
<legend><?php echo $legend; ?></legend>
<?php if (!$this->tableless): ?>
<table>
<?php endif; ?>
<?php echo implode('', $category); ?>
<?php if (!$this->tableless): ?>
</table>
<?php endif; ?>
</fieldset>
<?php endif; ?>
<?php endforeach; ?>

<div class="submit_container">
<input type="submit" class="submit" value="<?php echo $this->slabel; ?>" />
Expand Down

0 comments on commit acb854e

Please sign in to comment.