X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Ffacebookaction.php;h=6d42596e8e9a383d1eeb722e0d157481d775f27b;hb=a6fd4eb0a3b22b21940e00251b8964e231036b40;hp=d5b7ed0fb861a565be0fd3ed8a75c4e2a982775d;hpb=b264c03d32d04d7a33d28a5830848660f4484943;p=quix0rs-gnu-social.git diff --git a/lib/facebookaction.php b/lib/facebookaction.php index d5b7ed0fb8..6d42596e8e 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -17,9 +17,11 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/extlib/facebook/facebook.php'); +require_once INSTALLDIR.'/lib/facebookutil.php'; class FacebookAction extends Action { @@ -29,266 +31,236 @@ class FacebookAction extends Action parent::handle($args); } - function get_facebook() - { - $apikey = common_config('facebook', 'apikey'); - $secret = common_config('facebook', 'secret'); - return new Facebook($apikey, $secret); + function showLogo(){ + + global $xw; + + $this->showStylesheets(); + $this->showScripts(); + + $this->elementStart('a', array('class' => 'url home bookmark', + 'href' => common_local_url('public'))); + if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) { + $this->element('img', array('class' => 'logo photo', + 'src' => (common_config('site', 'logo')) ? + common_config('site', 'logo') : theme_path('logo.png'), + 'alt' => common_config('site', 'name'))); + } + + $this->element('span', array('class' => 'fn org'), common_config('site', 'name')); + $this->elementEnd('a'); + } - function update_profile_box($facebook, $fbuid, $user) + function showHeader($msg = null, $success = false) { + startFBML(); - $notice = $user->getCurrentNotice(); + $this->elementStart('fb:if-section-not-added', array('section' => 'profile')); + $this->elementStart('span', array('id' => 'add_to_profile')); + $this->element('fb:add-section-button', array('section' => 'profile')); + $this->elementEnd('span'); + $this->elementEnd('fb:if-section-not-added'); - # Need to include inline CSS for styling the Profile box + $this->showLogo(); - $style = ''; - $html = $this->render_notice($notice); + $this->elementStart('div', 'main_body'); - $fbml = "$content $html"; - $fbml .= "$content $html"; + } - $fbml_main = "$content $html"; + function showNav($selected = 'Home') + { - $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main); - } + $this->elementStart('dl', array("id" => 'site_nav_local_views')); + $this->element('dt', null, _('Local Views')); + $this->elementStart('dd'); - # Display methods + $this->elementStart('ul', array('class' => 'nav')); - function show_header($selected ='Home') - { + $this->elementStart('li', array('class' => + ($selected == 'Home') ? 'current' : 'facebook_home')); + $this->element('a', + array('href' => 'index.php', 'title' => _('Home')), _('Home')); + $this->elementEnd('li'); - # Add a timestamp to the CSS file so Facebook cache wont ignore our changes - $ts = filemtime(theme_file('facebookapp.css')); - $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; + $this->elementStart('li', + array('class' => + ($selected == 'Invite') ? 'current' : 'facebook_invite')); + $this->element('a', + array('href' => 'invite.php', 'title' => _('Invite')), _('Invite')); + $this->elementEnd('li'); - $header = ''; - # $header .=''; - $header .= ''; + $this->elementStart('li', + array('class' => + ($selected == 'Settings') ? 'current' : 'facebook_settings')); + $this->element('a', + array('href' => 'settings.php', + 'title' => _('Settings')), _('Settings')); + $this->elementEnd('li'); - $header .= - '' - .'' - .'' - .'' - .''; - $header .= '
'; + $this->elementEnd('ul'); - echo $header; + $this->elementEnd('dd'); + $this->elementEnd('dl'); } - function show_footer() + function showFooter() { - $footer = '
'; - echo $footer; + $this->elementEnd('div'); + $this->endXml(); } - function show_login_form() + function showInstructions() { + global $xw; - $loginform = - '

To add the Identi.ca application, you need to log into your Identi.ca account.

' - .'' - .' ' - .'' - .'

Login

' - .'
' - .'

Login with your username and password. Don\'t have a username yet?' - .' Register a new account.' - .'

' - .'
' - .'
' - .'
' - .'

' - .' ' - .' ' - .'

' - .'

' - .' ' - .' ' - .'

' - .'

' - .' ' - .'

' - .'
' - .'

' - .' Lost or forgotten password?' - .'

' - .'elementStart('dl', array('class' => 'system_notice')); + $this->element('dt', null, 'Page Notice'); + + $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' . + 'with your username and password. Don\'t have a username yet? '); + + $loginmsg_part2 = _(' a new account.'); + + $this->elementStart('dd'); + $this->elementStart('p'); + $this->text(sprintf($loginmsg_part1, common_config('site', 'name'))); + $this->element('a', + array('href' => common_local_url('register')), _('Register')); + $this->text($loginmsg_part2); + $this->elementEnd('dd'); + $this->elementEnd('dl'); } - function render_notice($notice) + function showStylesheets() { + global $xw; - global $config; + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookBaseCSS())); - $profile = $notice->getProfile(); - $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); - - $noticeurl = common_local_url('shownotice', array('notice' => $notice->id)); + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookThemeCSS())); + } - # XXX: we need to figure this out better. Is this right? - if (strcmp($notice->uri, $noticeurl) != 0 && preg_match('/^http/', $notice->uri)) { - $noticeurl = $notice->uri; - } + function showScripts() + { + global $xw; - $html = - '
  • ' - .'' - .'';
+    function showLoginForm($msg = null)
+    {
+        startFBML();
 
-        if ($profile->fullname) {
-            $html .= $profile->fullname;
-        } else {
-            $html .= $profile->nickname;
-        }
+        $this->showStylesheets();
+        $this->showScripts();
 
-        $html .=
-        '' - .'' . $profile->nickname . '' - .'

    ' . $notice->rendered . '

    ' - .'

    ' - .''; + $this->showLogo(); - if ($notice->source) { - $html .= _(' from '); - $html .= $this->source_link($notice->source); - } + $this->elementStart('div', array('class' => 'content')); + $this->element('h1', null, _('Login')); - if ($notice->reply_to) { - $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to)); - $html .= - ' (' . _('in reply to...') . ')'; + if ($msg) { + $this->element('fb:error', array('message' => $msg)); } - $html .= '

  • '; + $this->showInstructions(); - return $html; - } + $this->elementStart('div', array('id' => 'content_inner')); - function source_link($source) - { - $source_name = _($source); - - $html = ''; - - switch ($source) { - case 'web': - case 'xmpp': - case 'mail': - case 'omb': - case 'api': - $html .= $source_name; - break; - default: - $ns = Notice_source::staticGet($source); - if ($ns) { - $html .= '' . $ns->name . ''; - } else { - $html .= $source_name; - } - break; - } + $this->elementStart('form', array('method' => 'post', + 'class' => 'form_settings', + 'id' => 'login', + 'action' => 'index.php')); - $html .= ''; + $this->elementStart('fieldset'); + $this->element('legend', null, _('Login to site')); - return $html; - } - - function pagination($have_before, $have_after, $page, $fbaction, $args=null) - { + $this->elementStart('ul', array('class' => 'form_datas')); + $this->elementStart('li'); + $this->input('nickname', _('Nickname')); + $this->elementEnd('li'); + $this->elementStart('li'); + $this->password('password', _('Password')); + $this->elementEnd('li'); + $this->elementEnd('ul'); - $html = ''; + $this->submit('submit', _('Login')); + $this->elementEnd('form'); - if ($have_before || $have_after) { - $html = '