Example #1
0
 /**
  * Get html for creating of this component, depending on defined settings.
  * @return string html
  */
 public function GetOutputHtml()
 {
     $OnLoginFunc = "OnLogin" . GlobalCounter::GetCount();
     $html = "<script>\n";
     $html .= "function " . $OnLoginFunc . "() {\n";
     $html .= "  FB.getLoginStatus(function(response) {\n";
     $html .= "    if (response.status == 'connected') {\n";
     if ($this->onLoginJavaScript) {
         $html .= "      " . $this->onLoginJavaScript . ";\n";
     }
     if ($this->onLoginSubmitForm) {
         $html .= "      " . "document.getElementById('" . $this->onLoginSubmitForm . "').submit();\n";
     }
     $html .= "    }\n";
     $html .= "  })\n";
     $html .= "}\n";
     $html .= "</script>\n";
     $html .= " <fb:login-button ";
     if ($this->onLoginJavaScript != null || $this->onLoginSubmitForm) {
         $html .= "onlogin='******' ";
     }
     if ($this->size != null) {
         $html .= "size='" . $this->size . "' ";
     }
     if ($this->permissions != null) {
         $html .= "scope='" . $this->permissions . "' ";
     }
     $html .= ">";
     if ($this->text != null) {
         $html .= $this->text;
     }
     $html .= "</fb:login-button>";
     return $html;
 }
 /**
  * Get html for creating of this component, depending on defined settings.
  * @return string html
  */
 public function GetOutputHtml()
 {
     $functionName = "ShowRequestDialog" . GlobalCounter::GetCount();
     $html = "<script>\n";
     $html .= "function " . $functionName . "() {\n";
     $html .= "  if (graphApiInitialized != true) {\n";
     $html .= "    setTimeout('" . $functionName . "()', 100);\n";
     $html .= "    return;\n";
     $html .= "  }\n";
     $html .= "  FB.ui({method: 'apprequests', message: '";
     $html .= $this->message . "'";
     if ($this->title != null) {
         $html .= ", title: '" . $this->title . "'";
     }
     if ($this->friendId != null) {
         $html .= ", to: '" . $this->friendId . "'";
     }
     if ($this->additionalData != null) {
         $html .= ", data: '" . $this->additionalData . "'";
     }
     $html .= "});\n";
     $html .= "}\n";
     $html .= "</script>\n";
     switch ($this->commandType) {
         case "link":
             $html .= "<a style='cursor:pointer;" . $this->cssStyle . "' class='" . $this->cssClass . "' onclick=\"" . $functionName . "()\" >";
             $html .= $this->commandText;
             $html .= "</a>\n";
             break;
         case "button":
             $html .= "<input type='button' style='" . $this->cssStyle . "' class='" . $this->cssClass . "' onclick=\"" . $functionName . "()\"  value=\"";
             $html .= $this->commandText;
             $html .= "\" />\n";
             break;
         case "auto":
             $html .= "<script type=\"text/javascript\">";
             $html .= $functionName . "();\n";
             $html .= "</script>\n";
             break;
         default:
             throw new Exception('Request Dialog Control Error:  Unsupported Command Type: ' . $this->commandType);
     }
     return $html;
 }
Example #3
0
 /**
  * Get html for creating of this component, depending on defined settings.
  * @return string html
  */
 public function GetOutputHtml()
 {
     $OnOpenPopupFunc = "OnPopupFunc" . GlobalCounter::GetCount();
     $OnConfirmCallbackFunc = "OnConfirmCallbackFunc" . GlobalCounter::GetCount();
     $html = "<script>\n";
     $html .= "function " . $OnConfirmCallbackFunc . "(response) {\n";
     $html .= "if (response.authResponse != null) {\n";
     if ($this->onConfirmJavaScript != null) {
         $html .= $this->onConfirmJavaScript . ";\n";
     }
     if ($this->onConfirmSubmitForm != null) {
         $html .= "document.getElementById('" . $this->onConfirmSubmitForm . "').submit()";
     }
     $html .= "}\n";
     $html .= "}\n";
     $html .= "function " . $OnOpenPopupFunc . "() {\n";
     $html .= "if (graphApiInitialized == false) {\n";
     $html .= "  setTimeout('" . $OnOpenPopupFunc . "()', 100);\n";
     $html .= "  return;\n";
     $html .= "}\n";
     $html .= "FB.login(" . $OnConfirmCallbackFunc . ", {scope: '" . $this->permissions . "'});\n";
     $html .= "}\n";
     if ($this->commandType == 'auto') {
         $html .= $OnOpenPopupFunc . "();";
     }
     $html .= "</script>\n";
     switch ($this->commandType) {
         case "button":
             $html .= "<input type='button' onclick='" . $OnOpenPopupFunc;
             $html .= "()' id='PermissionsButton" . GlobalCounter::GetCount() . "' value='" . $this->commandText;
             $html .= "' style='" . $this->cssStyle . "' class='" . $this->cssClass . "' />";
             break;
         case "link":
             $html .= "<a style='cursor:pointer' onclick='" . $OnOpenPopupFunc;
             $html .= "()' id='PermissionsLink" . GlobalCounter::GetCount() . "' >" . $this->commandText . "</a>";
             break;
         case 'image':
             $html .= "<a style='cursor:pointer;" . $this->cssStyle . "' onclick='" . $OnOpenPopupFunc;
             $html .= "()' id='PermissionsLink" . GlobalCounter::GetCount() . "' ><img src='" . $this->image . "' alt='' /></a>";
             break;
         case 'auto':
             break;
         default:
             throw new Exception('Permissions Error:  Unsupported Command Type: ' . $this->commandType);
     }
     return $html;
 }
Example #4
0
 /**
  * Get html for creating of this component, depending on defined settings.
  * @return string html
  */
 public function GetOutputHtml()
 {
     $OnPublishPopupFunc = "OnPopupFunc" . GlobalCounter::GetCount();
     $OnPublishCallbackFunc = "OnPublishCallbackFunc" . GlobalCounter::GetCount();
     $html = "<script>\n";
     $html .= "function " . $OnPublishCallbackFunc . "(response) {\n";
     $html .= "if (response != null && response != undefined) {\n";
     if ($this->onPublishJavaScript != null) {
         $html .= $this->onPublishJavaScript . ";\n";
     }
     if ($this->onPublishSubmitForm != null) {
         $html .= "document.getElementById('" . $this->onPublishSubmitForm . "').submit()";
     }
     $html .= "}\n";
     $html .= "}\n";
     $html .= "function " . $OnPublishPopupFunc . "() {\n";
     $html .= "if (graphApiInitialized == false) {\n";
     $html .= "  setTimeout('" . $OnPublishPopupFunc . "()', 100);\n";
     $html .= "  return;\n";
     $html .= "}\n";
     $html .= "var publish = {\n";
     $html .= "  method: 'stream.publish',\n";
     if ($this->displayPopup) {
         $html .= "display: 'popup',\n";
     }
     $html .= "  message: '" . $this->userMessage . "',\n";
     $html .= "  target_id: '" . $this->friendId . "',\n";
     $html .= "  actor_id: '" . $this->pageId . "',\n";
     // open attachment
     $html .= "  attachment: {\n";
     $html .= "    name: '" . $this->name . "',\n";
     $html .= "    caption: '" . $this->caption . "',\n";
     $html .= "    description: '" . $this->description . "',\n";
     $html .= "    href: '" . $this->nameUrl . "',\n";
     // add media
     if ($this->media != null) {
         $html .= "    media:[" . $this->media->GetJSON() . "],\n";
     }
     // add properties
     if (count($this->properties) > 0) {
         $html .= "properties:{";
         $firstAdded = false;
         foreach ($this->properties as $property) {
             if ($firstAdded) {
                 $html .= ",";
             }
             $html .= $property->GetJSON();
             $firstAdded = true;
         }
         $html .= "}\n";
     }
     // close attachment
     $html .= "  },\n";
     // add action links
     if (count($this->actionLinks) > 0) {
         $html .= "action_links:[";
         $firstAdded = false;
         foreach ($this->actionLinks as $link) {
             if ($firstAdded) {
                 $html .= ",";
             }
             $html .= $link->GetJSON();
             $firstAdded = true;
         }
         $html .= "]\n";
     }
     // close object and publish
     $html .= "  };\n";
     $html .= "  FB.ui(publish, " . $OnPublishCallbackFunc . ");\n";
     $html .= "}\n";
     // auto publish for 'auto' command type
     if ($this->commandType == 'auto') {
         $html .= $OnPublishPopupFunc . "();";
     }
     $html .= "</script>\n";
     // create publish button/link
     switch ($this->commandType) {
         case "button":
             $html .= "<input type='button' onclick='" . $OnPublishPopupFunc;
             $html .= "()' id='PublishButton" . GlobalCounter::GetCount() . "' value='" . $this->commandText;
             $html .= "' style='" . $this->cssStyle . "' class='" . $this->cssClass . "' />";
             break;
         case "link":
             $html .= "<a style='cursor:pointer' onclick='" . $OnPublishPopupFunc;
             $html .= "()' id='PublishLink" . GlobalCounter::GetCount() . "' >" . $this->commandText . "</a>";
             break;
         case 'image':
             $html .= "<a style='cursor:pointer;" . $this->cssStyle . "' onclick='" . $OnPublishPopupFunc;
             $html .= "()' id='PublishLink" . GlobalCounter::GetCount() . "' ><img src='" . $this->image . "' alt='' /></a>";
             break;
         case 'auto':
             break;
         default:
             throw new Exception('Stream Publish Control Error:  Unsupported Command Type: ' . $this->commandType);
     }
     return $html;
 }
Example #5
0
 /**
  * Get html for creating of this component, depending on defined settings.
  * @return string html
  */
 public function GetOutputHtml()
 {
     $functionName = "ShowRequestDialog" . GlobalCounter::GetCount();
     $html = "<script>\n";
     $html .= "var invitedFriends = null;";
     $html .= "function " . $functionName . "() {\n";
     $html .= "  if (graphApiInitialized != true) {\n";
     $html .= "    setTimeout('" . $functionName . "()', 100);\n";
     $html .= "    return;\n";
     $html .= "  }\n";
     $html .= "  FB.ui({method: 'apprequests', message: '";
     $html .= $this->message . "'";
     if ($this->title != null) {
         $html .= ", title: '" . $this->title . "'";
     }
     if ($this->friendId != null) {
         $html .= ", to: '" . $this->friendId . "'";
     }
     if ($this->additionalData != null) {
         $html .= ", data: '" . $this->additionalData . "'";
     }
     if ($this->redirectUri != null) {
         $html .= ", redirect_uri: '" . $this->redirectUri . "'";
     }
     if ($this->filters != null) {
         $html .= ", filters: ['" . $this->filters . "']";
     }
     $html .= "}, function(response) {\n";
     $html .= "  if (response && response.to) {\n";
     $html .= "    invitedFriends = response.to;\n";
     if ($this->onSendRequestSubmitForm != null) {
         $html .= "    var form1 = document.getElementById('" . $this->onSendRequestSubmitForm . "');\n";
         $html .= "    var field = document.createElement('input');\n";
         $html .= "    field.setAttribute('type', 'hidden');\n";
         $html .= "    field.setAttribute('name', 'invitedFriends');\n";
         $html .= "    field.setAttribute('value', invitedFriends);\n";
         $html .= "    form1.appendChild(field);\n";
         $html .= "    form1.submit();\n";
     }
     $html .= "  }\n";
     $html .= "  else invitedFriends = null;\n";
     $html .= "})}\n";
     $html .= "</script>\n";
     switch ($this->commandType) {
         case "link":
             $html .= "<a style='cursor:pointer;" . $this->cssStyle . "' class='" . $this->cssClass . "' onclick=\"" . $functionName . "()\" >";
             $html .= $this->commandText;
             $html .= "</a>\n";
             break;
         case "button":
             $html .= "<input type='button' style='" . $this->cssStyle . "' class='" . $this->cssClass . "' onclick=\"" . $functionName . "()\"  value=\"";
             $html .= $this->commandText;
             $html .= "\" />\n";
             break;
         case "image":
             $html .= "<a style='cursor:pointer;" . $this->cssStyle . "' class='" . $this->cssClass . "' onclick=\"" . $functionName . "()\" ><img src='";
             $html .= $this->image;
             $html .= "' alt='' /></a>\n";
             break;
         case "auto":
             $html .= "<script type=\"text/javascript\">";
             $html .= $functionName . "();\n";
             $html .= "</script>\n";
             break;
         default:
             throw new Exception('Request Dialog Control Error:  Unsupported Command Type: ' . $this->commandType);
     }
     return $html;
 }