<?php

////////////////////////////////////////////////////////////////////////////////
//
// File:	function.FacebookShareDialog.php
// Project:	Facebook Dialog plugin for CMS Made Simple
// Version:	1.0
// Licence:	Free software under the GNU General Public License
// Created:	20131024, v1.0, Magal Hezi
//
////////////////////////////////////////////////////////////////////////////////

function smarty_cms_function_FacebookShareDialog($params, &$smarty) {

	$gCms = cmsms();
	$text = isset($params['text']) ? trim($params['text']) : "Share on Facebook";
	$class = isset($params['class']) ? 'class="' . trim($params['class']) . '" ' : "";

	$result = "";
	$result .= '<!-- Start Facebook dialog -->' . PHP_EOL;
	$result .= '<a href="#" '.$class;
	$result .= 'onclick="';
	$result .= 'window.open(';
	$result .= '\'https://www.facebook.com/sharer/sharer.php?u=\'+encodeURIComponent(location.href),';
	$result .= '\'facebook-share-dialog\', ';
	$result .= '\'width=626,height=436\');';
	$result .= 'return false;">';
	$result .= $text;
	$result .= '</a>';
	$result .= '<!-- End Facebook dialog -->';

	return $result;

}

function smarty_cms_help_function_FacebookShareDialog() {
	?>
	<h3>What does this do?</h3>
	<p>
Facebook offers an easy-to-use Share dialog that you can include on your web page or in your mobile web app so people can share links on their timeline, in groups, or to their friends via a Facebook Message.</p>
<h3>How do I use it?</h3>
	<p>Insert the tag <code>{FacebookShareDialog}</code> into your template or page (case sensitive).</p>
	<p>To ensure that web-designers have maximum control over customization, if you want to style the plugin's output, feel free to use additional external CSS rules in conjunction with the <code>class</code> parameter.</p>
<p>Alternatively, you can always use the <code>custom_url</code> parameters to set manually (or pass them via smarty) the url and title values of the current page without self detection functionality.</p>
<p><img src="https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/851565_597267243627925_220333382_n.png" alt="" /></p>
	
    
    
    <h3>What parameters does it take?	</h3>
	<ul>
      <li><em>(optional)</em> <code>text</code>
        <ul>
          <li>The default text displayed is: Share on Facebook<code></code></li>
        </ul>
      </li>
      <ul>
        <li>To change the default text there are two options.
          <ul>
            <li>to add your own image use the following
              <ul>
                <li><code>{FacebookShareDialog text='&lt;img src=&quot;images/share_pt.gif&quot; width=&quot;19&quot; height=&quot;19&quot;&gt;'}</code></li>
              </ul>
            </li>
            <li>to add text instead use:
              <ul>
                <li><code>{FacebookShareDialog text='Share'}</code></li>
              </ul>
            </li>
          </ul>
        </li>
      </ul>
		<li><em>(optional)</em> <code>class</code></li>
        <ul>
          <li>Populates the "<code>class</code>" attribute of the link, set the CSS class name</li>
          <li>E.g. <code>{FacebookShareDialog class="MyCssClassName"}</code></li>
        </ul>
        <p>
        <div id="fb-root"></div>
      <script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
      <div class="fb-follow" data-href="http://www.facebook.com/MagalFreelanceWebDeveloper" data-show-faces="true" data-font="segoe ui" data-width="460"></div>
</p>
</ul>
	<?php
}

function smarty_cms_about_function_FacebookShareDialog() {
	?>
<p>Author: <a href="http://www.facebook.com/MagalFreelanceWebDeveloper">Magal Hezi</a></p>
<p>Version: 1.0</p>
	<p>Update: Check for updates for this plugin at the <a href="http://dev.cmsmadesimple.org/projects/likebutton" target="_blank">CMS Made Simple Forge page</a></p>
	<p>Feature Requests: If you want to add others social bookmarking services or functionality, please let me know by opening a new feature request in the dedicated <strong>Feature Requests tab</strong> of the <a href="http://dev.cmsmadesimple.org/projects/likebutton" target="_blank">CMS Made Simple Forge page</a> for this plugin</p>
	<p>Bugs: If you want to submit a new bug, please let me know by opening a new bug in the dedicated <strong>Bug Tracker tab</strong> of the <a href="http://dev.cmsmadesimple.org/projects/likebutton" target="_blank">CMS Made Simple Forge page</a> for this plugin</p>
	<p>Licence: Free software under the GNU General Public License</p>
	<p>Change History:</p>
	<ul>
<li>Version 1.0</li>
		<ul>
			<li>First release</li>
		</ul>
	</ul>
	<?php
}
?>
