Skip to content

Commit

Permalink
FIX: TemplateGlobalProvider does not work with shortcut namespaces, a…
Browse files Browse the repository at this point in the history
…nd fixed package name
  • Loading branch information
Mellisa Hankins committed Jul 29, 2015
1 parent 384c675 commit d1ec0ad
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 78 deletions.
2 changes: 1 addition & 1 deletion code/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Milkyway Multimedia
* Collector.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class Collector {
Expand Down
2 changes: 1 addition & 1 deletion code/Contracts/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Milkyway Multimedia
* Provider.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
interface Provider {
Expand Down
2 changes: 1 addition & 1 deletion code/Contracts/TextParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Milkyway Multimedia
* PostParser.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/

Expand Down
5 changes: 3 additions & 2 deletions code/Control/RemoveMultipleFbRoots.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function preRequest(SS_HTTPRequest $request, Session $session, DataModel
}

public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
if(singleton('env')->get('include_facebook_root_div'))
$response->setBody(str_replace('<body>', '<body><div id="fb-root"></div>', $response->getBody()));
if(singleton('env')->get('include_facebook_root_div')) {
$response->setBody(str_replace('</body>', '<div id="fb-root"></div></body>', $response->getBody()));
}
}
}
2 changes: 1 addition & 1 deletion code/Parsers/DefaultParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Milkyway Multimedia
* AutolinkParser.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/

Expand Down
2 changes: 1 addition & 1 deletion code/Profiles/SocialFeed_Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Milkyway Multimedia
* SocialFeed_Facebook.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class SocialFeed_Facebook extends SocialFeed_Profile
Expand Down
2 changes: 1 addition & 1 deletion code/Profiles/SocialFeed_GooglePlaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Milkyway Multimedia
* SocialFeed_GooglePlaces.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class SocialFeed_GooglePlaces extends SocialFeed_Profile {
Expand Down
2 changes: 1 addition & 1 deletion code/Profiles/SocialFeed_GooglePlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Milkyway Multimedia
* SocialFeed_GooglePlus.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class SocialFeed_GooglePlus extends SocialFeed_Profile {
Expand Down
2 changes: 1 addition & 1 deletion code/Profiles/SocialFeed_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Milkyway Multimedia
* SocialFeed_Page.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/

Expand Down
2 changes: 1 addition & 1 deletion code/Profiles/SocialFeed_Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Milkyway Multimedia
* SocialFeed_Profile.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/

Expand Down
2 changes: 1 addition & 1 deletion code/Profiles/SocialFeed_Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Milkyway Multimedia
* SocialFeed_Twitter.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class SocialFeed_Twitter extends SocialFeed_Profile {
Expand Down
2 changes: 1 addition & 1 deletion code/Profiles/SocialFeed_Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Milkyway Multimedia
* SocialFeed_GooglePlus.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class SocialFeed_Youtube extends SocialFeed_Profile {
Expand Down
2 changes: 1 addition & 1 deletion code/Providers/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Milkyway Multimedia
* Facebook.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class Facebook extends Oauth implements \Flushable
Expand Down
2 changes: 1 addition & 1 deletion code/Providers/GooglePlaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Milkyway Multimedia
* GooglePlaces.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class GooglePlaces extends HTTP {
Expand Down
2 changes: 1 addition & 1 deletion code/Providers/GooglePlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Milkyway Multimedia
* GooglePlus.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class GooglePlus extends HTTP {
Expand Down
2 changes: 1 addition & 1 deletion code/Providers/Model/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Milkyway Multimedia
* HTTP.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
abstract class HTTP implements Provider {
Expand Down
2 changes: 1 addition & 1 deletion code/Providers/Model/Internal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Milkyway Multimedia
* Db.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/

Expand Down
2 changes: 1 addition & 1 deletion code/Providers/Model/Oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Milkyway Multimedia
* HTTPProvider.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
abstract class Oauth extends HTTP {
Expand Down
2 changes: 1 addition & 1 deletion code/Providers/SS_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Milkyway Multimedia
* SS_Blog.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/

Expand Down
2 changes: 1 addition & 1 deletion code/Providers/Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Milkyway Multimedia
* Twitter.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class Twitter extends Oauth {
Expand Down
127 changes: 72 additions & 55 deletions code/Utilities.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php namespace Milkyway\SS\SocialFeed;

use TemplateGlobalProvider;
use Milkyway\SS\Director;
use SocialFeed_Facebook;
use SocialFeed_Profile;
Expand All @@ -12,54 +11,68 @@
* Milkyway Multimedia
* Utilities.php
*
* @package reggardocolaianni.com
* @package milkyway-multimedia/ss-social-feed
* @author Mellisa Hankins <mell@milkywaymultimedia.com.au>
*/
class Utilities implements TemplateGlobalProvider {
public static function require_facebook_script($facebook = null, $parent = null) {
if(!$facebook)
$facebook = singleton('SocialFeed_Facebook');
class Utilities implements \TemplateGlobalProvider
{
public static function require_facebook_script($facebook = null, $parent = null)
{
if (!$facebook) {
$facebook = singleton('SocialFeed_Facebook');
}

$appId = $facebook->setting('AppID', $parent);
$appId = $facebook->setting('AppID', $parent);

if(!$appId && $facebook = SocialFeed_Facebook::get()->first())
$appId = $facebook->setting('AppID', $parent);
if (!$appId && $facebook = SocialFeed_Facebook::get()->first()) {
$appId = $facebook->setting('AppID', $parent);
}

if($appId)
singleton('assets')->defer(sprintf(Director::protocol() . 'connect.facebook.net/%s/all.js#xfbml=1&appId=%s', i18n::get_locale(), $appId));
if ($appId) {
singleton('assets')->defer(sprintf(Director::protocol() . 'connect.facebook.net/%s/all.js#xfbml=1&appId=%s',
i18n::get_locale(), $appId));
}

singleton('env')->set('include_facebook_root_div', true);
}

public static function require_twitter_script() {
singleton('assets')->defer(Director::protocol() . 'platform.twitter.com/widgets.js');
public static function require_twitter_script()
{
singleton('assets')->defer(Director::protocol() . 'platform.twitter.com/widgets.js');
}

public static function require_google_plus_script() {
singleton('assets')->customScript("window.___gcfg = {lang: '" . str_replace('_', '-', i18n::get_locale()) . "'};", 'GooglePlus-Locale');
singleton('assets')->defer(Director::protocol() . 'apis.google.com/js/plusone.js', true);
public static function require_google_plus_script()
{
singleton('assets')->customScript("window.___gcfg = {lang: '" . str_replace('_', '-',
i18n::get_locale()) . "'};", 'GooglePlus-Locale');
singleton('assets')->defer(Director::protocol() . 'apis.google.com/js/plusone.js', true);
}

public static function require_google_platform_script() {
public static function require_google_platform_script()
{
singleton('assets')->defer(Director::protocol() . 'apis.google.com/js/platform.js', true);
}

private static $_addThis_included;

public static function addThisJS($profileID = '', $parent = null, $config = []) {
if(!self::$_addThis_included) {
if(!$profileID) {
if($profile = SocialFeed_Profile::get()->first())
public static function addThisJS($profileID = '', $parent = null, $config = [])
{
if (!self::$_addThis_included) {
if (!$profileID) {
if ($profile = SocialFeed_Profile::get()->first()) {
$profileID = $profile->setting('AddThis', $parent);
}

if(!$profileID)
if (!$profileID) {
$profileID = singleton('SocialFeed_Profile')->setting('AddThis', $parent);
}

if(!$profileID)
if (!$profileID) {
return;
}
}

if(!count($config)) {
if (!count($config)) {
$config = array(
'data_track_addressbar' => false,
'ui_cobrand' => SiteConfig::current_site_config()->Title,
Expand All @@ -74,54 +87,58 @@ public static function addThisJS($profileID = '', $parent = null, $config = [])
</script>
', 'AddThis-Configuration');

singleton('assets')->defer('http://s7.addthis.com/js/300/addthis_widget.js#pubid=' . $profileID, true);
singleton('assets')->defer('http://s7.addthis.com/js/300/addthis_widget.js#pubid=' . $profileID, true);
}
}

public static function facebookLink($parent = null)
{
if($id = singleton('SocialFeed_Facebook')->setting('Username', $parent))
return Controller::join_links(singleton('SocialFeed_Facebook')->config()->url, $id);
public static function facebookLink($parent = null)
{
if ($id = singleton('SocialFeed_Facebook')->setting('Username', $parent)) {
return Controller::join_links(singleton('SocialFeed_Facebook')->config()->url, $id);
}

return '';
}
return '';
}

public static function twitterLink($parent = null)
{
if($id = singleton('SocialFeed_Twitter')->setting('Username', $parent))
return Controller::join_links(singleton('SocialFeed_Twitter')->config()->url, $id);
public static function twitterLink($parent = null)
{
if ($id = singleton('SocialFeed_Twitter')->setting('Username', $parent)) {
return Controller::join_links(singleton('SocialFeed_Twitter')->config()->url, $id);
}

return '';
}
return '';
}

public static function googlePlusLink($parent = null)
{
if($id = singleton('SocialFeed_GooglePlus')->setting('Username', $parent))
return Controller::join_links(singleton('SocialFeed_GooglePlus')->config()->url, $id);
public static function googlePlusLink($parent = null)
{
if ($id = singleton('SocialFeed_GooglePlus')->setting('Username', $parent)) {
return Controller::join_links(singleton('SocialFeed_GooglePlus')->config()->url, $id);
}

return '';
}
return '';
}

public static function instagramLink()
{
if($id = SiteConfig::current_site_config()->Instagram_Username)
return Controller::join_links('http://instagram.com', $id);
public static function instagramLink()
{
if ($id = SiteConfig::current_site_config()->Instagram_Username) {
return Controller::join_links('http://instagram.com', $id);
}

return '';
}
return '';
}

public static function get_template_global_variables() {
public static function get_template_global_variables()
{
return array(
'require_facebook_script',
'require_twitter_script',
'require_google_plus_script',
'require_google_platform_script',
'addThisJS',

'facebookLink',
'twitterLink',
'googlePlusLink',
'instagramLink',
'facebookLink',
'twitterLink',
'googlePlusLink',
'instagramLink',
);
}
}
4 changes: 2 additions & 2 deletions templates/Includes/social-plugins/AddThis_ShareModule.ss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="addthis_toolbox addthis_default_style" data-addthis-url="<% if $addThisUrl %>$addThisUrl<% else_if $Top.Link %>{$absoluteBaseURL}{$Top.Link.Trim('/','l')}<% else %>$absoluteBaseURL<% end_if %>"<% if $addThisTitle %> data-addthis-title="$addThisTitle"<% end_if %>>
<span class="addthis_toolbox addthis_default_style" data-addthis-url="<% if $addThisUrl %>$addThisUrl<% else_if $Top.Link %>{$absoluteBaseURL}{$Top.Link.Trim('/','l')}<% else %>$absoluteBaseURL<% end_if %>"<% if $addThisTitle %> data-addthis-title="$addThisTitle"<% end_if %>>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_pinterest_share"></a>
<a class="addthis_button_email"></a>
<a class="addthis_button_compact"></a><% if $addThisCounter %> <a class="addthis_counter addthis_bubble_style"></a><% end_if %>
</div>
</span>

$addThisJS($addThisProfileID)

0 comments on commit d1ec0ad

Please sign in to comment.