View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}
{zone-data:component-name}

Zend_Service_Facebook
{zone-data}

{zone-data:proposer-list}
[Ian Warner|mailto:iwarner@triangle-solutions.com]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 17th November 2008: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Service_Facebook will be a set of Helper Classes to OOP the Facebook FBML Components. These consist of elements such as
FB:Dialog
FB:TypeAhead


One thing Facebook does require also is JS to be written in its own proprietary FBJS and these helpers would also create FBJS components also to handle tasks such as AJAX
 
Something to take note of though is that Bebo also use the Facebook Platform and Helpers good for Facebook will be good for Bebo in most parts, Bebo is several generations behind. So the naming of this component may need to reflect that is can be cross site, but will utilise the Facebook Open Platform


{zone-data}

{zone-data:references}
* [Facebook|http://www.facebook.com/]
* [Facebook Wiki|http://wiki.developers.facebook.com/index.php/Main_Page]
{zone-data}

{zone-data:requirements}
* This component *will* create Helper Classes for all Facebook FBML elements.
* This component *will* strive to provide Helpers for common FBJS tasks.
{zone-data}

{zone-data:dependencies}
* Zend_Exception
{zone-data}

{zone-data:operation}
Helpers classes are simply called from the View, replacing the usualwith a nice OOP way of doing things $this->facebookDialog();
This will allow the application developer to concentrate on the application and not worry about Facebook changing there platform on a far too regular cycle.

{zone-data}

{zone-data:milestones}
* Milestone 1: Community Feedback on already coded Helpers required to progress
* Milestone 2: Based on the above create the required Unit Tests for all the Helpers
* Milestone 3: Add any missing Helpers
* Milestone 4: Document all Helpers and best practice use
* Milestone 5: Working prototype checked into the incubator when requirements are met.
* Milestone 6: Finalise Documentation and Testing and deploy.
{zone-data}

{zone-data:class-list}
* Zend_View_Helper_Facebook_Dialog
* Zend_View_Helper_Facebook_Board
* Zend_View_Helper_Facebook_Comments

etc
{zone-data}

{zone-data:use-cases}
This demonstrates the Facebook Comments UI Component Use Case:

{code}
$this->FacebookComments(array(
    'xID'                 => '1324657890',
    'numberPosts'         => 5,
    'returnURL'           => $this->path,
    'title'               => 'Wall',
    'sendNotificationUid' => $this->userID
));
{code}
{zone-data}

{zone-data:skeletons}
 
This demonstrates the actual Helper I use now for the Facebook comments component other Helpers are written in a similar way.
{code}

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * Helper class to produce the Facebook Comments
 *
 *
 * // Invoke the Facebook Comments Helper
 * {$this->FacebookComments(array('xID' => '123465798'))}
 *
 *
 * @category  FrameWork
 * @package   Helpers
 * @copyright ©2008 Triangle Solutions Ltd
 * @version   SVN: $Id: $
 *
 * @todo For comment deletion a user should be able to delete anything they have posted.
 * @todo A user should also have control over there profile / team / league comments and delete all posts in that sphere.
 */

// {{{ constants

// }}}
// {{{ GLOBALS

// }}}
// {{{ Helpers_FacebookComments()

/**
 * @category FrameWork
 * @package  Helpers
 */
class Helpers_FacebookComments
{
    // {{{ properties

    /**
     * Vars to set the defaults for the request invite forms
     */
    private $defaults = array(
      'xID'                 => 'comments_1', // String The unique identifier for this set of comments.
                                             //        Comments can contain alphanumeric characters (Aa-Zz, 0-9),
                                             //        hyphens (-) and underscores (_) only.
      'canPost'             => 'true',       // Bool   Indicates whether the viewing user can post on this comment set.
      'canDelete'           => 'false',      // Bool   Indicates whether the viewing user can delete any post on this comment set.
      'numberPosts'         => 10,           // Int    The maximum number of posts to display.
      'title'               => false,        // String The title of the comments box
      'callBackURL'         => false,        // String The URL to refetch this configuration. (Default value is the current page.)
      'returnURL'           => false,        // String The URL where the user is returned after selecting a "back" link.
                                             //        (Default value is the current page.)
      'showForm'            => false,        // Bool   Boolean whether to show the form (canpost "true" only) for inline posting.
                                             //        Posts using this form will not go to a see-all page after posting, but rather refresh the page.
      'sendNotificationUid' => false,        // Int    User ID to send a notification to upon someone posting a comment. (Only one uid allowed).
     );


    // }}}
    // {{{ facebookComments()

    /**
     * Method to render the Facebook Comments element
     *
     * @param  string $params Array of attribute values
     * @return string
     *
     * @link   http://wiki.developers.facebook.com/index.php/Fb:comments
     */
    public function facebookComments($params = array())
    {
        // Merge the two arrays to overwrite default values.
        $this->params = array_merge($this->defaults, $params);

        // If there is a return URL then create the tag to include in the FBML
        if (!empty($this->params['returnURL'])) {
            $returnURL = 'returnurl="' . $this->params['returnURL'] . '"';
        } else {
            $returnURL = '';
        }

        // If there is a callback URL then create the tag to include in the FBML
        if (!empty($this->params['callBackURL'])) {
            $callBackURL = 'callbackurl="' . $this->params['callBackURL'] . '"';
        } else {
            $callBackURL = '';
        }

        // Process the array of user that can delete and check whether the logged
        // in user is one of these.
        if (!empty($_POST['fb_sig_user'])) {
            $canDelete = 'true';
        } else {
            $canDelete = 'false';
        }

        // If there is a title then create the tag to include in the FBML
        if (!empty($this->params['title'])) {
            $title = '' . $this->params['title'] . '';
        } else {
            $title = '';
        }

        // If there is a callback URL then create the tag to include in the FBML
        if (!empty($this->params['sendNotificationUid'])) {
            $sendNotificationUid = 'send_notification_uid="' . $this->params['sendNotificationUid'] . '"';
        } else {
            $sendNotificationUid = '';
        }

        // Create the string
        $string =
        <<
         
          
            showform="true" numposts="{$this->params['numberPosts']}" {$returnURL} {$callBackURL} {$sendNotificationUid}>
            {$title}
          
         
FBML;

        return $string;
    }

    // }}}

}

// }}}

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * c-hanging-comment-ender-p: nil
 * End:
 */
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>