From 10123c075ffedb3dae91ad71b8c51e8f0df49d06 Mon Sep 17 00:00:00 2001 From: wilson29thid Date: Mon, 15 Sep 2014 23:37:54 +0000 Subject: [PATCH] Got it working using include() instead of ->Render() and using instead of in the template --- .../class.steamprofile.plugin.php | 6 +- plugins/steamprofile/design/style.css | 26 ++-- .../models/class.steamprofilemodel.php | 118 +++++++++--------- plugins/steamprofile/views/panel.php | 66 +++++----- .../steamprofile/views/steamcommunityid.php | 40 +++--- 5 files changed, 129 insertions(+), 127 deletions(-) diff --git a/plugins/steamprofile/class.steamprofile.plugin.php b/plugins/steamprofile/class.steamprofile.plugin.php index b1dfc85..d628e1e 100644 --- a/plugins/steamprofile/class.steamprofile.plugin.php +++ b/plugins/steamprofile/class.steamprofile.plugin.php @@ -87,9 +87,10 @@ private function CheckAuthentication($OpenIDRequest) { * * @param Gdn_Controller $Sender */ - public function ProfileController_SteamProfileOpenID_Create(&$Sender) { + public function ProfileController_SteamProfileOpenID_Create($Sender) { // Grabbing the $_GET array, processed by our framework $RequestGet = Gdn::Request()->Get(); + //die( '
' . print_r($RequestGet, true) . '
' ); // Nabbing the mode of the OpenID request, if any $OpenIDMode = GetValue('openid_mode', $RequestGet); @@ -146,7 +147,8 @@ public function ProfileController_EditMyAccountAfter_Handler($Sender) { // Assisnging the retrieved data to the form field and loading up the form field view $Sender->SetData('SteamID64', $SteamID64); - $Sender->Render($this->GetView('steamcommunityid.php')); + //$Sender->Render($this->GetView('steamcommunityid.php')); + include($this->GetView('steamcommunityid.php')); } /** diff --git a/plugins/steamprofile/design/style.css b/plugins/steamprofile/design/style.css index 9813d22..6a19915 100644 --- a/plugins/steamprofile/design/style.css +++ b/plugins/steamprofile/design/style.css @@ -1,14 +1,14 @@ -dt.SteamMemberSince { } -dd.SteamMemberSince { } -dt.SteamPlayedGame { text-align: center; } -dd.SteamPlayedGame { } -dt.SteamPlayingTime { } -dd.SteamPlayingTime { } -dt.SteamRating { } -dd.SteamRating { } -dt.SteamUpdated { } -dd.SteamUpdated { } - -.SteamAvatar { text-align: center; } -.SteamBasicInfo { } +dt.SteamMemberSince { } +dd.SteamMemberSince { } +dt.SteamPlayedGame { text-align: center; } +dd.SteamPlayedGame { } +dt.SteamPlayingTime { } +dd.SteamPlayingTime { } +dt.SteamRating { } +dd.SteamRating { } +dt.SteamUpdated { } +dd.SteamUpdated { } + +.SteamAvatar { text-align: center; } +.SteamBasicInfo { } .SteamProfile { } \ No newline at end of file diff --git a/plugins/steamprofile/models/class.steamprofilemodel.php b/plugins/steamprofile/models/class.steamprofilemodel.php index 765b293..ae0bb30 100644 --- a/plugins/steamprofile/models/class.steamprofilemodel.php +++ b/plugins/steamprofile/models/class.steamprofilemodel.php @@ -1,59 +1,59 @@ -SQL - ->Select() - ->From('SteamProfileCache') - ->Where('SteamID64', $SteamID) - ->Where('DateRetrieved >', Gdn_Format::ToDateTime(strtotime('-5 minutes'))) - ->Get() - ->Firstrow(); - - // Any cached entries? - if ($CachedProfile) { - // ...if so, load up the profile XML into a SimpleXMLElement... - $CommunityProfile = simplexml_load_string($CachedProfile->ProfileXML, 'SimpleXMLElement', LIBXML_NOCDATA); - // set the DateRetrieved of the cached record and go - $CommunityProfile->DateRetrieved = $CachedProfile->DateRetrieved; - return $CommunityProfile; - } else { - // ...if not, attempt to grab the profile's XML - $CommunityProfile = simplexml_load_file('http://steamcommunity.com/profiles/'.$SteamID.'?xml=1', 'SimpleXMLElement', LIBXML_NOCDATA); - - // Were we able to successfully fetch the profile? - if ($CommunityProfile && !isset($CommunityProfile->error)) { - // ...if so, insert or update the profile XML into the cache table - $this->SQL->Replace( - 'SteamProfileCache', - array('SteamID64' => $SteamID, 'ProfileXML' => $CommunityProfile->asXML(), 'DateRetrieved' => Gdn_Format::ToDateTime()), - array('SteamID64' => $SteamID), - TRUE - ); - - // Set the DateRetrieved record to now and go - $CommunityProfile->DateRetrieved = Gdn_Format::ToDateTime(); - return $CommunityProfile; - } - } - } - - // If we hit this point, something bad has happened. - return FALSE; - } -} +SQL + ->Select() + ->From('SteamProfileCache') + ->Where('SteamID64', $SteamID) + ->Where('DateRetrieved >', Gdn_Format::ToDateTime(strtotime('-5 minutes'))) + ->Get() + ->Firstrow(); + + // Any cached entries? + if ($CachedProfile) { + // ...if so, load up the profile XML into a SimpleXMLElement... + $CommunityProfile = simplexml_load_string($CachedProfile->ProfileXML, 'SimpleXMLElement', LIBXML_NOCDATA); + // set the DateRetrieved of the cached record and go + $CommunityProfile->DateRetrieved = $CachedProfile->DateRetrieved; + return $CommunityProfile; + } else { + // ...if not, attempt to grab the profile's XML + $CommunityProfile = simplexml_load_file('http://steamcommunity.com/profiles/'.$SteamID.'?xml=1', 'SimpleXMLElement', LIBXML_NOCDATA); + + // Were we able to successfully fetch the profile? + if ($CommunityProfile && !isset($CommunityProfile->error)) { + // ...if so, insert or update the profile XML into the cache table + $this->SQL->Replace( + 'SteamProfileCache', + array('SteamID64' => $SteamID, 'ProfileXML' => $CommunityProfile->asXML(), 'DateRetrieved' => Gdn_Format::ToDateTime()), + array('SteamID64' => $SteamID), + TRUE + ); + + // Set the DateRetrieved record to now and go + $CommunityProfile->DateRetrieved = Gdn_Format::ToDateTime(); + return $CommunityProfile; + } + } + } + + // If we hit this point, something bad has happened. + return FALSE; + } +} diff --git a/plugins/steamprofile/views/panel.php b/plugins/steamprofile/views/panel.php index 8dfa91f..6542137 100644 --- a/plugins/steamprofile/views/panel.php +++ b/plugins/steamprofile/views/panel.php @@ -1,33 +1,33 @@ - -
-

Steam Profile

-
-
Avatar Icon
-
- Data('SteamProfile')->steamID64, $this->Data('SteamProfile')->steamID, '%text'); ?>
- Data('SteamProfile')->stateMessage); ?> -
- Data('SteamProfile')->privacyState == 'public'): ?> -
Member Since
-
Data('SteamProfile')->memberSince); ?>
-
Steam Rating
-
Data('SteamProfile')->steamRating); ?>
-
Playing Time
-
Data('SteamProfile')->hoursPlayed2Wk.' hrs past 2 weeks'); ?>
- Data('MostPlayedGame', FALSE)) : ?> -
<?php echo Gdn_Format::Text($this->Data('MostPlayedGame')->gameName); ?>
-
- Data('MostPlayedGame')->gameName); ?>
- Data('MostPlayedGame')->hoursPlayed.' hrs / '.$this->Data('MostPlayedGame')->hoursOnRecord).' hrs'; ?>
- Data('SteamProfile')->steamID64.'/stats/'.$this->Data('MostPlayedGame')->statsName, 'View stats', '%text'); ?> -
- -
-
Data('SteamProfile')->steamID64.'/games?tab=all', 'View All Games', '%text'); ?>
-
-
Data('SteamProfile')->steamID64.'/wishlist', 'View Wishlist', '%text'); ?>
- -
Updated
-
Data('SteamProfile')->DateRetrieved, TRUE); ?>
-
-
+ +
+

Steam Profile

+
+
Avatar Icon
+
+ Data('SteamProfile')->steamID64, $this->Data('SteamProfile')->steamID, '%text'); ?>
+ Data('SteamProfile')->stateMessage); ?> +
+ Data('SteamProfile')->privacyState == 'public'): ?> +
Member Since
+
Data('SteamProfile')->memberSince); ?>
+
Steam Rating
+
Data('SteamProfile')->steamRating); ?>
+
Playing Time
+
Data('SteamProfile')->hoursPlayed2Wk.' hrs past 2 weeks'); ?>
+ Data('MostPlayedGame', FALSE)) : ?> +
<?php echo Gdn_Format::Text($this->Data('MostPlayedGame')->gameName); ?>
+
+ Data('MostPlayedGame')->gameName); ?>
+ Data('MostPlayedGame')->hoursPlayed.' hrs / '.$this->Data('MostPlayedGame')->hoursOnRecord).' hrs'; ?>
+ Data('SteamProfile')->steamID64.'/stats/'.$this->Data('MostPlayedGame')->statsName, 'View stats', '%text'); ?> +
+ +
+
Data('SteamProfile')->steamID64.'/games?tab=all', 'View All Games', '%text'); ?>
+
+
Data('SteamProfile')->steamID64.'/wishlist', 'View Wishlist', '%text'); ?>
+ +
Updated
+
Data('SteamProfile')->DateRetrieved, TRUE); ?>
+
+
diff --git a/plugins/steamprofile/views/steamcommunityid.php b/plugins/steamprofile/views/steamcommunityid.php index 7a4e756..362576e 100644 --- a/plugins/steamprofile/views/steamcommunityid.php +++ b/plugins/steamprofile/views/steamcommunityid.php @@ -1,20 +1,20 @@ - -
  • - Form->Label('Steam Profile'); - - // Do we happen to already have a Steam ID for our current user? - if ($this->Data('SteamID64')) { - // If so, we just output it. Nothing fancy. - echo '
    '.T('Steam ID').': '.Gdn_Format::Text($this->Data('SteamID64')).'
    '; - } else { - // If not, we drop in a button and set the stage for OpenID magic. - echo Anchor( - Img('plugins/steamprofile/design/images/sits_small.png', array('alt' => 'Sign in through Steam')), - $this->Data('SteamAuthenticationUrl'), - '', - array('title' => 'Sign in through Steam') - ); - } - ?> -
  • + +
  • + Form->Label('Steam Profile'); + + // Do we happen to already have a Steam ID for our current user? + if ($Sender->Data('SteamID64')) { + // If so, we just output it. Nothing fancy. + echo '
    '.T('Steam ID').': '.Gdn_Format::Text($Sender->Data('SteamID64')).'
    '; + } else { + // If not, we drop in a button and set the stage for OpenID magic. + echo Anchor( + Img('plugins/steamprofile/design/images/sits_small.png', array('alt' => 'Sign in through Steam')), + $Sender->Data('SteamAuthenticationUrl'), + '', + array('title' => 'Sign in through Steam') + ); + } + ?> +