Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed Nov 13, 2014
1 parent 9c05539 commit 1bd1e70
Show file tree
Hide file tree
Showing 11 changed files with 376 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OS
.DS_Store
Thumbs.db
37 changes: 37 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name":"fritzmg/contao-sharebuttons",
"description":"Simple Contao extension to provide share buttons as a module and content element",
"keywords":["contao", "share", "buttons", "social", "facebook", "twitter"],
"type":"contao-module",
"homepage":"http://www.inspiredminds.at",
"license":"GPL-2.0",
"authors":[
{
"name":"Fritz Michael Gschwantner",
"homepage":"http://www.inspiredminds.at",
"email":"[email protected]",
"role":"Developer"
}
],
"support":{
"email":"[email protected]",
"issues":"https://github.com/fritzmg/contao-sharebuttons/issues",
"source":"https://github.com/fritzmg/contao-sharebuttons",
"forum":"https://community.contao.org/de"
},
"require":{
"php":">=5.2",
"contao/core":"~3.0",
"contao-community-alliance/composer-installer":"*"
},
"replace": {
"contao-legacy/sharebuttons": "*"
},
"extra":{
"contao":{
"sources":{
"system/modules/sharebuttons":"system/modules/sharebuttons"
}
}
}
}
44 changes: 44 additions & 0 deletions system/modules/sharebuttons/classes/ModuleShareButtons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* Contao Open Source CMS
*
* simple extension to provide a share buttons module
*
* Copyright (C) 2013 Fritz Michael Gschwantner
*
* @package sharebuttons
* @link http://www.inspiredminds.at
* @author Fritz Michael Gschwantner <[email protected]>
* @license GPL-2.0
*/


class ModuleShareButtons extends Module
{
/**
* Template
* @var string
*/
protected $strTemplate = 'sharebuttons_default';

/**
* Generate module
*/
protected function compile()
{
if( $this->sharebuttons_template )
{
$this->Template = new FrontendTemplate( $this->sharebuttons_template );
}

// add settings to template
$this->Template->facebook = $this->sharebuttons_facebook;
$this->Template->twitter = $this->sharebuttons_twitter;
$this->Template->gplus = $this->sharebuttons_gplus;
$this->Template->linkedin = $this->sharebuttons_linkedin;
$this->Template->xing = $this->sharebuttons_xing;
$this->Template->mail = $this->sharebuttons_mail;
}
}
?>
32 changes: 32 additions & 0 deletions system/modules/sharebuttons/config/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* Contao Open Source CMS
*
* simple extension to provide a share buttons module
*
* Copyright (C) 2013 Fritz Michael Gschwantner
*
* @package sharebuttons
* @link http://www.inspiredminds.at
* @author Fritz Michael Gschwantner <[email protected]>
* @license GPL-2.0
*/


/**
* Register the classes
*/
ClassLoader::addClasses(array
(
'ModuleShareButtons' => 'system/modules/sharebuttons/classes/ModuleShareButtons.php'
));


/**
* Register the templates
*/
TemplateLoader::addFiles(array
(
'sharebuttons_default' => 'system/modules/sharebuttons/templates'
));
23 changes: 23 additions & 0 deletions system/modules/sharebuttons/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Contao Open Source CMS
*
* simple extension to provide a share buttons module
*
* Copyright (C) 2013 Fritz Michael Gschwantner
*
* @package sharebuttons
* @link http://www.inspiredminds.at
* @author Fritz Michael Gschwantner <[email protected]>
* @license GPL-2.0
*/


/**
* Front end modules
*/
array_insert($GLOBALS['FE_MOD']['miscellaneous'], 1, array
(
'sharebuttons' => 'ModuleShareButtons'
));
111 changes: 111 additions & 0 deletions system/modules/sharebuttons/dca/tl_module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

/**
* Contao Open Source CMS
*
* simple extension to provide a share buttons module
*
* Copyright (C) 2013 Fritz Michael Gschwantner
*
* @package sharebuttons
* @link http://www.inspiredminds.at
* @author Fritz Michael Gschwantner <[email protected]>
* @license GPL-2.0
*/


/**
* Add palettes to tl_module
*/
$GLOBALS['TL_DCA']['tl_module']['palettes']['sharebuttons'] = '{title_legend},name,headline,type;{sharebuttons_legend},sharebuttons_facebook,sharebuttons_twitter,sharebuttons_gplus,sharebuttons_linkedin,sharebuttons_xing,sharebuttons_mail,sharebuttons_template;{expert_legend},cssID,align,space';

/**
* Add fields to tl_module
*/
$GLOBALS['TL_DCA']['tl_module']['fields']['sharebuttons_facebook'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['sharebuttons_facebook'],
'default' => true,
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "tinyint(1) unsigned NOT NULL default '1'"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['sharebuttons_twitter'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['sharebuttons_twitter'],
'default' => true,
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "tinyint(1) unsigned NOT NULL default '1'"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['sharebuttons_gplus'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['sharebuttons_gplus'],
'default' => true,
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "tinyint(1) unsigned NOT NULL default '1'"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['sharebuttons_linkedin'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['sharebuttons_linkedin'],
'default' => true,
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "tinyint(1) unsigned NOT NULL default '1'"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['sharebuttons_xing'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['sharebuttons_xing'],
'default' => true,
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "tinyint(1) unsigned NOT NULL default '1'"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['sharebuttons_mail'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['sharebuttons_mail'],
'default' => true,
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "tinyint(1) unsigned NOT NULL default '1'"
);

$GLOBALS['TL_DCA']['tl_module']['fields']['sharebuttons_template'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['sharebuttons_template'],
'default' => 'sharebuttons_default',
'exclude' => true,
'inputType' => 'select',
'options_callback' => array('tl_sharebuttons_module', 'getSharebuttonsTemplates'),
'eval' => array('mandatory'=>true,'tl_class'=>'w50'),
'sql' => "varchar(32) NOT NULL default 'sharebuttons_default'"
);

class tl_sharebuttons_module extends Backend
{
public function getSharebuttonsTemplates(DataContainer $dc)
{
$intPid = $dc->activeRecord->pid;

if (\Input::get('act') == 'overrideAll')
{
$intPid = \Input::get('id');
}

return $this->getTemplateGroup('sharebuttons_', $intPid);
}
}

?>
24 changes: 24 additions & 0 deletions system/modules/sharebuttons/languages/de/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* Contao Open Source CMS
*
* simple extension to provide a share buttons module
*
* Copyright (C) 2013 Fritz Michael Gschwantner
*
* @package sharebuttons
* @link http://www.inspiredminds.at
* @author Fritz Michael Gschwantner <[email protected]>
* @license GPL-2.0
*/

$GLOBALS['TL_LANG']['sharebuttons']['share_title'] = "Teilen:";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_facebook'] = "auf Facebook teilen";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_twitter'] = "auf Twitter teilen";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_gplus'] = "auf Google+ teilen";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_linkedin'] = "auf LinkedIn teilen";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_xing'] = "auf Xing teilen";
$GLOBALS['TL_LANG']['sharebuttons']['mail_subject'] = "Website Empfehlung";

?>
29 changes: 29 additions & 0 deletions system/modules/sharebuttons/languages/de/modules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* Contao Open Source CMS
*
* simple extension to provide a share buttons module
*
* Copyright (C) 2013 Fritz Michael Gschwantner
*
* @package sharebuttons
* @link http://www.inspiredminds.at
* @author Fritz Michael Gschwantner <[email protected]>
* @license GPL-2.0
*/


$GLOBALS['TL_LANG']['FMD']['sharebuttons'] = array('Share buttons', '');

$GLOBALS['TL_LANG']['tl_module']['sharebuttons_legend'] = "Einstellungen";

$GLOBALS['TL_LANG']['tl_module']['sharebuttons_facebook'] = array('Zeige Facebook','Zeige Facebook teilen button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_twitter'] = array('Zeige Twitter','Zeige Twitter teilen button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_gplus'] = array('Zeige Google+','Zeige Google+ teilen button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_linkedin'] = array('Zeige LinkedIn','Zeige LinkedIn teilen button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_xing'] = array('Zeige Xing','Zeige Xing teilen button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_mail'] = array('Zeige E-Mail','Zeige e-mail teilen button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_template'] = array('Template','Verwendetes Frontend Template. Beginnt mit sharebuttons_');

?>
24 changes: 24 additions & 0 deletions system/modules/sharebuttons/languages/en/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* Contao Open Source CMS
*
* simple extension to provide a share buttons module
*
* Copyright (C) 2013 Fritz Michael Gschwantner
*
* @package sharebuttons
* @link http://www.inspiredminds.at
* @author Fritz Michael Gschwantner <[email protected]>
* @license GPL-2.0
*/

$GLOBALS['TL_LANG']['sharebuttons']['share_title'] = "Share:";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_facebook'] = "share on Facebook";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_twitter'] = "share on Twitter";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_gplus'] = "share on Google+";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_linkedin'] = "share on LinkedIn";
$GLOBALS['TL_LANG']['sharebuttons']['share_on_xing'] = "share on Xing";
$GLOBALS['TL_LANG']['sharebuttons']['mail_subject'] = "Website recommendation";

?>
29 changes: 29 additions & 0 deletions system/modules/sharebuttons/languages/en/modules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* Contao Open Source CMS
*
* simple extension to provide a share buttons module
*
* Copyright (C) 2013 Fritz Michael Gschwantner
*
* @package sharebuttons
* @link http://www.inspiredminds.at
* @author Fritz Michael Gschwantner <[email protected]>
* @license GPL-2.0
*/


$GLOBALS['TL_LANG']['FMD']['sharebuttons'] = array('Share buttons', '');

$GLOBALS['TL_LANG']['tl_module']['sharebuttons_legend'] = "Share settings";

$GLOBALS['TL_LANG']['tl_module']['sharebuttons_facebook'] = array('Enable Facebook','Enable Facebook share button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_twitter'] = array('Enable Twitter','Enable Twitter share button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_gplus'] = array('Enable Google+','Enable Google+ share button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_linkedin'] = array('Enable LinkedIn','Enable LinkedIn share button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_xing'] = array('Enable Xing','Enable Xing share button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_mail'] = array('Enable E-Mail','Enable e-mail share button');
$GLOBALS['TL_LANG']['tl_module']['sharebuttons_template'] = array('Template','Used Template for frontend rendering. Starts with sharebuttons_');

?>
20 changes: 20 additions & 0 deletions system/modules/sharebuttons/templates/sharebuttons_default.html5
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<ul class="share">
<?php if ($this->facebook): ?>
<li class="first"><a class="facebook" href="share/index.php?p=facebook[&]u=<?php echo urlencode($this->Environment->base . $this->Environment->request); ?>[&]t=<?php echo urlencode($objPage->pageTitle); ?>" rel="nofollow" title="{{label::sharebuttons:share_on_facebook}}" onclick="window.open(this.href, '', 'width=760,height=470,modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no'); return false;">Facebook</a></li>
<?php endif; ?>
<?php if ($this->twitter): ?>
<li><a class="twitter" href="share/index.php?p=twitter[&]u=<?php echo urlencode($this->Environment->base . $this->Environment->request); ?>[&]t=<?php echo urlencode($objPage->pageTitle); ?>" rel="nofollow" title="{{label::sharebuttons:share_on_twitter}}" onclick="window.open(this.href, '', 'width=760,height=470,modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no'); return false;">Twitter</a></li>
<?php endif; ?>
<?php if ($this->gplus): ?>
<li><a class="gplus" href="https://plus.google.com/share?url=<?php echo urlencode($this->Environment->base . $this->Environment->request); ?>" rel="nofollow" title="{{label::sharebuttons:share_on_gplus}}" onclick="window.open(this.href, '', 'width=760,height=470,modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no'); return false;">Google+</a></li>
<?php endif; ?>
<?php if ($this->linkedin): ?>
<li><a class="linkedin" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php echo urlencode($this->Environment->base . $this->Environment->request); ?>" rel="nofollow" title="{{label::sharebuttons:share_on_linkedin}}" target="blank">LinkedIn</a></li>
<?php endif; ?>
<?php if ($this->xing): ?>
<li><a class="xing" href="https://www.xing.com/app/user?op=share;url=<?php echo urlencode($this->Environment->base . $this->Environment->request); ?>" rel="nofollow" title="{{label::sharebuttons:share_on_xing}}" target="blank">Xing</a></li>
<?php endif; ?>
<?php if ($this->mail): ?>
<li class="last"><a class="mail" href="mailto:?subject={{label::sharebuttons:mail_subject}}:%20<?php echo urlencode($objPage->pageTitle); ?>[&]body=<?php echo urlencode($this->Environment->base . $this->Environment->request); ?>">Mail</a></li>
<?php endif; ?>
</ul>

0 comments on commit 1bd1e70

Please sign in to comment.