Ignore:
Timestamp:
Dec 23, 2010, 2:45:50 AM (13 years ago)
Author:
rub
Message:

Add admin page conf
Add full option for firt social plugin

Location:
extensions/FacebookPlug/Plugin/include
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/FacebookPlug/Plugin/include/picture.inc.php

    r8221 r8241  
    2424}
    2525
    26 function fbp_AddSocial($content, &$smarty)
     26function fbp_header($content, &$smarty)
    2727{
    28   // iframe implementation
    29 /*  $fbp_content = '
    30 <iframe src="http://www.facebook.com/plugins/like.php?href={$SRC_IMG}&amp;layout=standard&amp;show_faces=true&amp;width={$WIDTH_IMG}&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:{$WIDTH_IMG}px; height:80px;" allowTransparency="true"></iframe>
    31 ';*/
     28  global $conf;
    3229
    33   // XFBML implementation
    34   // async method
    35 /*  $fbp_content = '
    36 <div id="fb-root"></div>
     30  // replace tag html
     31  $search = '<html ';
     32  $replacement = '<html xmlns:fb="http://www.facebook.com/2008/fbml" ';
     33
     34  $content = preg_replace('#'.$search.'#', $replacement, $content);
     35
     36  // Piwigo init
     37  if ($conf['fbp']['async_script'])
     38  {
     39    // async method
     40    $fbp_content = '
     41<div id="fb-root"></div>
    3742<script>
    3843{literal}
    3944  window.fbAsyncInit = function() {
    4045    FB.init({
    41       appId  : \'111499825588662\',
     46      appId  : \''.FACEBOOK_APP_ID.'\',
    4247      status : true, // check login status
    4348      cookie : true, // enable cookies to allow the server to access the session
     
    5560{/literal}
    5661</script>
    57 ';*/
    58   // sync method
    59   $fbp_content = '
     62';
     63  }
     64  else
     65  {
     66    // sync method
     67    $fbp_content = '
    6068<div id="fb-root"></div>
    6169<script src="http://connect.facebook.net/en_US/all.js"></script>
    6270<script>
    6371  FB.init({ldelim}
    64     appId  : \'111499825588662\',
     72    appId  : \''.FACEBOOK_APP_ID.'\',
    6573    status : true, // check login status
    6674    cookie : true, // enable cookies to allow the server to access the session
     
    7078<script src="http://connect.facebook.net/{$LANGUAGE}/all.js#xfbml=1"></script>
    7179';
     80  }
     81
     82  $search = '<div id="the_page">';
     83  return preg_replace('#'.$search.'#', $fbp_content.$search, $content);
     84}
     85
     86function fbp_add_social($content, &$smarty)
     87{
     88  global $conf;
     89  $fbp_content .= '<div id="fb-xfbml">';
     90
     91  // iframe implementation
     92/*  $fbp_content = '
     93<iframe src="http://www.facebook.com/plugins/like.php?href={$SRC_IMG}&amp;layout=standard&amp;show_faces=true&amp;width={$WIDTH_IMG}&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:{$WIDTH_IMG}px; height:80px;" allowTransparency="true"></iframe>
     94';*/
     95
     96  // XFBML implementation
    7297  /*$fbp_content .= '
    7398<fb:like href="{$SRC_IMG}" show_faces="true" width="{$WIDTH_IMG}"></fb:like>
    7499';*/
    75100  $fbp_content .= '
    76 <fb:like href="{$FBP_URL_PICTURE}" show_faces="true" width="{$WIDTH_IMG}"></fb:like>
     101<fb:like href="{$FBP_URL_PICTURE}" layout="{$FBP_SOCIAL_PLUGIN_LIKE_BUTTON.layout}" show_faces="{if $FBP_SOCIAL_PLUGIN_LIKE_BUTTON.show_faces}true{else}false{/if}" width="{$WIDTH_IMG}" action="{$FBP_SOCIAL_PLUGIN_LIKE_BUTTON.action}" colorscheme="{$FBP_SOCIAL_PLUGIN_LIKE_BUTTON.colorscheme}"></fb:like>
    77102';
     103
     104  $fbp_content .= '</div>';
    78105
    79106  return $content.$fbp_content;
     
    82109function fbp_loc_begin_picture()
    83110{
    84   global $template, $user, $page;
     111  global $template, $user, $page, $conf, $picture;
    85112
    86113  // set prefilter
    87114  $template->set_prefilter('header', 'fbp_header');
    88   $template->set_prefilter('default_content', 'fbp_AddSocial');
    89   // Always use full url for FB social plugin
    90   //~ set_make_full_url();
    91   // define language
    92   $template->assign('LANGUAGE', $user['language']);
    93   // define picture FB link
    94   set_make_full_url();
    95   $template->assign('FBP_URL_PICTURE', make_picture_url(array('image_id' => $page['image_id'])));
    96   unset_make_full_url();
     115  //~ $template->set_prefilter('header', 'fbp_add_fb_init');
     116  if ($conf['fbp']['social_plugin_like_button']['enabled'])
     117  {
     118    $template->set_prefilter('default_content', 'fbp_add_social');
     119  }
    97120}
    98121
    99 function fbp_loc_end_picture()
     122//~ function fbp_loc_end_picture()
     123function fbp_render_element_content($content, $current_picture)
    100124{
    101   // Restore url
    102   //~ unset_make_full_url();
     125  global $template, $user, $page, $conf, $picture;
     126
     127  if ($conf['fbp']['social_plugin_like_button']['enabled'])
     128  {
     129    //~ $template->set_prefilter('default_content', 'fbp_add_social');
     130    // Always use full url for FB social plugin
     131    //~ set_make_full_url();
     132    // define language
     133    $template->assign('LANGUAGE', $user['language']);
     134    // define picture FB link
     135    set_make_full_url();
     136    if ($conf['fbp']['social_plugin_like_button']['url_type'] == 'image')
     137    {
     138      $fbp_url_picture = get_element_url($picture['current']);
     139    }
     140    else
     141    {
     142      $fbp_url_picture = make_picture_url(array('image_id' => $page['image_id']));
     143    }
     144    unset_make_full_url();
     145    $template->assign('FBP_URL_PICTURE', $fbp_url_picture);
     146    $template->assign('FBP_SOCIAL_PLUGIN_LIKE_BUTTON', $conf['fbp']['social_plugin_like_button']);
     147  }
     148  return $content;
    103149}
    104 
    105 function fbp_header($content, &$smarty)
    106 {
    107   $search = '#<html #';
    108 
    109   $replacement = '<html xmlns:fb="http://www.facebook.com/2008/fbml" ';
    110 
    111   return preg_replace($search, $replacement, $content);
    112 }
    113 
    114 add_event_handler('loc_begin_picture', 'fbp_loc_begin_picture');
    115 add_event_handler('loc_end_picture', 'fbp_loc_end_picture');
    116 
    117150
    118151function ftp_loc_end_section_init()
    119152{
    120   global $conf, $user, $page;
     153  global $conf;
    121154
    122   $fbp_ip_check = '66.220.';
    123   //~ $fbp_ip_check = '127.0.';
    124   // No restristion for facebook user
    125   if (preg_match('/'. $fbp_ip_check . '/', $_SERVER["REMOTE_ADDR"]))
     155  if ($conf['fbp']['social_plugin_like_button']['enabled'])
    126156  {
    127     //Allow guest access
    128     $conf['guest_access'] = true;
    129     // No forbidden categorie
    130     $user['forbidden_categories'] = '';
    131     $user['level'] = max($conf['available_permission_levels']);
    132     $page['rank_of'][$page['image_id']] = 0;
    133     $page['items'] = array_flip($page['rank_of']);
     157    if ($conf['fbp']['allow_fb_access_private_page'])
     158    {
     159      global $user, $page;
     160
     161      // No restristion for facebook user
     162      if (preg_match('/'.FBP_IP_FB. '/', $_SERVER["REMOTE_ADDR"]))
     163      {
     164        //Allow guest access
     165        $conf['guest_access'] = true;
     166        // No forbidden categorie
     167        $user['forbidden_categories'] = '';
     168        $user['level'] = max($conf['available_permission_levels']);
     169        $page['rank_of'][$page['image_id']] = 0;
     170        $page['items'] = array_flip($page['rank_of']);
     171      }
     172    }
    134173  }
    135174}
    136 add_event_handler('loc_end_section_init', 'ftp_loc_end_section_init');
     175
     176if ($conf['fbp']['social_plugin_like_button']['enabled'])
     177{
     178  add_event_handler('loc_begin_picture', 'fbp_loc_begin_picture');
     179  add_event_handler('render_element_content', 'fbp_render_element_content', null, 2);
     180  //~ add_event_handler('loc_end_picture', 'fbp_loc_end_picture');
     181  add_event_handler('loc_end_section_init', 'ftp_loc_end_section_init');
     182}
    137183
    138184?>
Note: See TracChangeset for help on using the changeset viewer.