update landing page for connect button

This commit is contained in:
Marion Muszynski 2016-04-08 15:31:40 +02:00
parent ace3f99035
commit 1d26459616
5 changed files with 50 additions and 1 deletions

View File

@ -22,6 +22,7 @@ class AdminLandingPages extends AdminTab {
VALUES (
DEFAULT,
'.(int) (bool) Tools::getValue('enabled').',
'.(int) (bool) Tools::getValue('connect_button').',
"'.pSQL(Tools::str2url($name)).'",
"'.pSQL(Tools::getValue('text1')).'",
"'.pSQL(Tools::getValue('text2')).'",
@ -74,9 +75,10 @@ class AdminLandingPages extends AdminTab {
Db::getInstance()->ExecuteS('
UPDATE `'._DB_PREFIX_.'landing_page`
SET `enabled` = '.(int) (bool) Tools::getValue('enabled').',
`connect_button` = '.(int) (bool) Tools::getValue('connect_button').',
`name` = "'.pSQL(Tools::str2url($name)).'",
`text1` = "'.pSQL(Tools::getValue('text1')).'",
`text2` = "'.pSQL(Tools::getValue('text2')).'",
`text2` = "'.pSQL(Tools::getValue('text2')).'",
`tag` = "'.pSQL(Tools::getValue('tag'), true).'"
WHERE `id_landing_page` = '.$id_landing_page.'
');
@ -147,6 +149,7 @@ class AdminLandingPages extends AdminTab {
<th>'.$this->l('URL chunk').'</th>
<th id="cust_sort">'.$this->l('Customers').'</th>
<th style="width: 55px;">'.$this->l('Enabled').'</th>
<th style="width: 55px;">'.$this->l('Connect').'</th>
<th style="width: 35px;">'.$this->l('Actions').'</th>
</tr>';
@ -157,6 +160,7 @@ class AdminLandingPages extends AdminTab {
<td>http://'.$_SERVER['SERVER_NAME'].'/authentification?create_account=1&lp='.$page['name'].'</td>
<td>'.(isset($counts[$page['id_landing_page']])? $counts[$page['id_landing_page']]: '0').'</td>
<td>'.($page['enabled']? $this->l('Yes'): $this->l('No')).'</td>
<td>'.($page['connect_button']? $this->l('Yes'): $this->l('No')).'</td>
<td>
<img style="cursor: pointer;" onclick="itemEdition('.$page['id_landing_page'].')" title="'.$this->l('Edit this landing page').'" alt="" src="../img/admin/edit.gif" />
</td>
@ -286,6 +290,15 @@ class AdminLandingPages extends AdminTab {
<div class="clear"></div>
</div>';
echo '<label>'.$this->l('Connect Button:').'</label>
<div class="margin-form">
<div id="enabled" style="float: left;">
<input name="connect_button" type="radio" value="0"'.($this->curlp? ($this->curlp['connect_button'] == 0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('No').'&nbsp;&nbsp;&nbsp;<input name="connect_button" type="radio" value="1"'.($this->curlp && $this->curlp['connect_button'] == 1? ' checked="checked"': '').' /> '.$this->l('Yes').'
<sup> *</sup>
</div>
<div class="clear"></div>
</div>';
echo '<label>'.$this->l('Text 1:').'</label>
<div class="margin-form">
<div id="enabled" style="float: left;">

View File

@ -0,0 +1,12 @@
{if $connect_button == 1}
<style type="text/css">
#authentication #center_column #account-creation_container p#account_form_bottom{
padding: 6px 50px;
width: inherit;
text-align: right;
}
</style>
<p class="cart_navigation" id="account_form_bottom">
<a id="SubmitLogin" href="{$link->getPageLink('authentication.php')}">{l s='log in'}</a>
</p>
{/if}

View File

@ -68,6 +68,7 @@ class LandingPages extends Module {
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'landing_page` (
`id_landing_page` INTEGER NOT NULL AUTO_INCREMENT,
`enabled` BOOL NOT NULL,
`connect_button` BOOL NOT NULL,
`name` VARCHAR(255) NOT NULL,
`text1` VARCHAR(255) NOT NULL,
`text2` VARCHAR(255) NOT NULL,
@ -93,6 +94,7 @@ class LandingPages extends Module {
if(!parent::install()
|| !$this->registerHook('adminCustomers')
|| !$this->registerHook('createAccountForm')
|| !$this->registerHook('createAccountFormBottom')
|| !$this->registerHook('createAccount')) {
return FALSE;
}
@ -224,4 +226,24 @@ class LandingPages extends Module {
return $this->display(__FILE__, 'authentication.tpl');
}
}
public function hookCreateAccountFormBottom($params) {
global $smarty, $cookie;
$connect_button = 0;
if($name = Tools::getValue('lp')) {
if($landing = Db::getInstance()->getRow('
SELECT `connect_button`
FROM `'._DB_PREFIX_.'landing_page`
WHERE `enabled` = 1
AND `name` = "'.pSQL($name).'"
')) {
$connect_button = $landing['connect_button'];
}
}
$smarty->assign(array(
'connect_button' => $connect_button,
));
return $this->display(__FILE__, 'authentication_bottom.tpl');
}
}

View File

@ -328,6 +328,7 @@ class AuthController extends AuthControllerCore {
public function displayContent() {
Tools::safePostVars();
self::$smarty->assign('errors', $this->errors);
self::$smarty->assign('HOOK_CREATE_ACCOUNT_FORM_BOTTOM', Module::hookExec('createAccountFormBottom', array()));
self::$smarty->display(_PS_THEME_DIR_.'authentication.tpl');
}

View File

@ -431,6 +431,7 @@ $(function(){ldelim}
<input type="submit" name="submitAccount" id="submitAccount" value="{l s='Register'}" class="exclusive" onclick="if($('#newsletter:checked').length == 0) { alert('{l s='Please accept our terms of use to continue' js=1}'); return false; }" />
<span><sup>*</sup>{l s='Required field'}</span>
</p>
{$HOOK_CREATE_ACCOUNT_FORM_BOTTOM}
</form>
</div>