mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 06:07:32 +02:00
Code deduplication in signup_shortcodes for XUP login
Also fixed variable passing weirdness in API of e_user_provider
This commit is contained in:
@@ -66,105 +66,85 @@ class signup_shortcodes extends e_shortcode
|
|||||||
function sc_signup_xup_login($parm)
|
function sc_signup_xup_login($parm)
|
||||||
{
|
{
|
||||||
$pref = e107::getPref('social_login_active');
|
$pref = e107::getPref('social_login_active');
|
||||||
$tp = e107::getParser();
|
if (empty($pref)) return '';
|
||||||
|
|
||||||
$size = empty($parm['size']) ? '3x' : $parm['size'];
|
$size = empty($parm['size']) ? '3x' : $parm['size'];
|
||||||
$class = empty($parm['class']) ? 'btn btn-primary' : $parm['class'] ;
|
$class = empty($parm['class']) ? 'btn btn-primary' : $parm['class'] ;
|
||||||
|
|
||||||
|
return $this->generateXupLoginButtons("login", $size, $class);
|
||||||
if(!empty($pref))
|
|
||||||
{
|
|
||||||
$text = "";
|
|
||||||
$manager = new SocialLoginConfigManager(e107::getConfig());
|
|
||||||
$providers = $manager->getValidConfiguredProviderConfigs();
|
|
||||||
|
|
||||||
foreach($providers as $p=>$v)
|
|
||||||
{
|
|
||||||
if($v['enabled'] == 1)
|
|
||||||
{
|
|
||||||
|
|
||||||
// $text .= "<a href='".e107::getUrl()->create('system/xup/login?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'><img class='e-tip' title='Register using your {$p} account' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' /></a>";
|
|
||||||
|
|
||||||
$ic = strtolower($p);
|
|
||||||
|
|
||||||
switch ($ic)
|
|
||||||
{
|
|
||||||
case 'windowslive':
|
|
||||||
$ic = 'windows';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 'signup' Creates a new XUP user if not found, otherwise it logs the person in.
|
|
||||||
|
|
||||||
if (defset('FONTAWESOME') && in_array($ic, e107::getMedia()->getGlyphs()))
|
|
||||||
$button = "<span title='" . $tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_SIGNUP, $p) . "'>" . $tp->toGlyph('fa-' . $ic, array('size' => $size, 'fw' => true)) . "</span>";
|
|
||||||
elseif (is_file(e107::getFolder('images') . "xup/{$ic}.png"))
|
|
||||||
$button = "<img class='e-tip' title='" . $tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_SIGNUP, $p) . "' src='" . e_IMAGE_ABS . "xup/{$ic}.png' alt='' />";
|
|
||||||
else
|
|
||||||
$button = "<span title='" . $tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_SIGNUP, $p) . "'>$p</span>";
|
|
||||||
|
|
||||||
$text .= " <a title='".$tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_SIGNUP, $p)." ' role='button' class='signup-xup ".$class."' href='".e107::getUrl()->create('system/xup/signup?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'>".$button."</a> ";
|
|
||||||
}
|
|
||||||
//TODO different icon options. see: http://zocial.smcllns.com/
|
|
||||||
}
|
|
||||||
|
|
||||||
// $text .= "<hr />";
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - template
|
// TODO - template
|
||||||
function sc_signup_xup_signup($parm)
|
function sc_signup_xup_signup($parm)
|
||||||
{
|
{
|
||||||
$pref = e107::getPref('social_login_active');
|
$pref = e107::getPref('social_login_active');
|
||||||
$tp = e107::getParser();
|
if (empty($pref)) return '';
|
||||||
|
|
||||||
|
$size = empty($parm['size']) ? '2x' : $parm['size'];
|
||||||
|
$class = empty($parm['class']) ? 'btn btn-primary' : $parm['class'] ;
|
||||||
|
|
||||||
|
if($size == '2x')
|
||||||
if(!empty($pref))
|
|
||||||
{
|
{
|
||||||
$text = "";
|
$class .= ' btn-lg';
|
||||||
$manager = new SocialLoginConfigManager(e107::getConfig());
|
|
||||||
$providers = $manager->getValidConfiguredProviderConfigs();
|
|
||||||
|
|
||||||
$size = empty($parm['size']) ? '2x' : $parm['size'];
|
|
||||||
$class = empty($parm['class']) ? 'btn btn-primary' : $parm['class'] ;
|
|
||||||
|
|
||||||
if($size == '2x')
|
|
||||||
{
|
|
||||||
$class .= ' btn-lg';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach($providers as $p=>$v)
|
|
||||||
{
|
|
||||||
if($v['enabled'] == 1)
|
|
||||||
{
|
|
||||||
$ic = strtolower($p);
|
|
||||||
|
|
||||||
switch ($ic)
|
|
||||||
{
|
|
||||||
case 'windowslive':
|
|
||||||
$ic = 'windows';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defset('FONTAWESOME') && in_array($ic, e107::getMedia()->getGlyphs()))
|
|
||||||
$button = "<span title='" . $tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_REG, $p) . "'>" . $tp->toGlyph('fa-' . $ic, array('size' => $size, 'fw' => true)) . "</span>";
|
|
||||||
elseif (is_file(e107::getFolder('images') . "xup/{$ic}.png"))
|
|
||||||
$button = "<img class='e-tip' title='" . $tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_REG, $p) . "' src='" . e_IMAGE_ABS . "xup/{$ic}.png' alt='' />";
|
|
||||||
else
|
|
||||||
$button = "<span title='" . $tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_REG, $p) . "'>$p</span>";
|
|
||||||
$text .= " <a class='signup-xup " . $class . "' role='button' href='" . e107::getUrl()->create('system/xup/signup?provider=' . $p . '&back=' . base64_encode(e_REQUEST_URL)) . "'>" . $button . "</a> ";
|
|
||||||
}
|
|
||||||
//TODO different icon options. see: http://zocial.smcllns.com/
|
|
||||||
}
|
|
||||||
|
|
||||||
// $text .= "<hr />";
|
|
||||||
return $text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->generateXupLoginButtons("signup", $size, $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $type
|
||||||
|
* @param $size
|
||||||
|
* @param $class
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function generateXupLoginButtons($type, $size, $class)
|
||||||
|
{
|
||||||
|
$text = "";
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
$lan_plugin_social_xup = '';
|
||||||
|
switch ($type)
|
||||||
|
{
|
||||||
|
case "login":
|
||||||
|
$lan_plugin_social_xup = LAN_PLUGIN_SOCIAL_XUP_REG;
|
||||||
|
break;
|
||||||
|
case "signup":
|
||||||
|
$lan_plugin_social_xup = LAN_PLUGIN_SOCIAL_XUP_SIGNUP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$manager = new SocialLoginConfigManager(e107::getConfig());
|
||||||
|
$providers = $manager->getValidConfiguredProviderConfigs();
|
||||||
|
|
||||||
|
foreach ($providers as $p => $v)
|
||||||
|
{
|
||||||
|
if ($v['enabled'] == 1)
|
||||||
|
{
|
||||||
|
$ic = strtolower($p);
|
||||||
|
|
||||||
|
switch ($ic)
|
||||||
|
{
|
||||||
|
case 'windowslive':
|
||||||
|
$ic = 'windows';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defset('FONTAWESOME') && in_array($ic, e107::getMedia()->getGlyphs()))
|
||||||
|
$button = "<span title='" . $tp->lanVars($lan_plugin_social_xup, $p) . "'>" . $tp->toGlyph('fa-' . $ic, array('size' => $size, 'fw' => true)) . "</span>";
|
||||||
|
elseif (is_file(e107::getFolder('images') . "xup/{$ic}.png"))
|
||||||
|
$button = "<img class='e-tip' title='" . $tp->lanVars($lan_plugin_social_xup, $p) . "' src='" . e_IMAGE_ABS . "xup/{$ic}.png' alt='' />";
|
||||||
|
else
|
||||||
|
$button = "<span title='" . $tp->lanVars($lan_plugin_social_xup, $p) . "'>$p</span>";
|
||||||
|
|
||||||
|
$callback_url = e107::getUserProvider($p)->generateCallbackUrl($type, e_REQUEST_URL);
|
||||||
|
$text .= " <a title='" . $tp->lanVars($lan_plugin_social_xup, $p) . " ' role='button' class='signup-xup $class' href='$callback_url'>$button</a> ";
|
||||||
|
}
|
||||||
|
//TODO different icon options. see: http://zocial.smcllns.com/
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
function sc_signup_form_open()
|
function sc_signup_form_open()
|
||||||
{
|
{
|
||||||
|
@@ -1157,7 +1157,7 @@ class e_user_provider
|
|||||||
public function setBackUrl($url, $action)
|
public function setBackUrl($url, $action)
|
||||||
{
|
{
|
||||||
# system/xup/login by default
|
# system/xup/login by default
|
||||||
$this->_config['callback'] = $this->generateCallbackUrl($this->getProvider(), $action, $url);
|
$this->_config['callback'] = $this->generateCallbackUrl($action, $url);
|
||||||
$this->respawnHybridauth();
|
$this->respawnHybridauth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1519,12 +1519,12 @@ class e_user_provider
|
|||||||
* @param string $backUrl
|
* @param string $backUrl
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function generateCallbackUrl($provider, $xupAction = "login", $backUrl = null)
|
public function generateCallbackUrl($xupAction = "login", $backUrl = null)
|
||||||
{
|
{
|
||||||
return e107::getUrl()->create(
|
return e107::getUrl()->create(
|
||||||
"system/xup/$xupAction",
|
"system/xup/$xupAction",
|
||||||
array(
|
array(
|
||||||
'provider' => $provider,
|
'provider' => $this->getProvider(),
|
||||||
'back' => $backUrl,
|
'back' => $backUrl,
|
||||||
),
|
),
|
||||||
array('full' => true, 'encode' => false)
|
array('full' => true, 'encode' => false)
|
||||||
|
Reference in New Issue
Block a user