00001 <?php 00002 if(!defined('__PRAGYAN_CMS')) 00003 { 00004 header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); 00005 echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>"; 00006 echo '<hr/>'.$_SERVER['SERVER_SIGNATURE']; 00007 exit(1); 00008 } 00019 global $sourceFolder; 00020 require_once("$sourceFolder/widgetFramework.class.php"); 00021 00022 class facebook extends widgetFramework 00023 { 00024 public $type; 00025 public $pageurl; 00026 public $color; 00027 public $show_face; 00028 public $width; 00029 public $height; 00030 public $layout; 00031 public $stream; 00032 public $header; 00033 public $makeunique; 00034 public $divid; 00035 public $divclass; 00036 public $globaldisable; 00037 00038 public function __construct($widgetId,$widgetInstanceId,$pageId) 00039 { 00040 $this->configs = array ( 00041 array ( 00042 'name' => 'type', 00043 'type' => 'select', 00044 'options' => 'Facebook Page|Site|Each Page', 00045 'displaytext' => 'Connect to', 00046 'default' => 'Facebook Page', 00047 'global' => 0 00048 ), 00049 array ( 00050 'name' => 'show_face', 00051 'type' => 'select', 00052 'options' => 'Yes|No', 00053 'displaytext' => 'Display the profile pic of people', 00054 'default' => 'yes', 00055 'global' => 0 00056 ), 00057 array ( 00058 'name' => 'color', 00059 'type' => 'select', 00060 'options' => 'Light|Dark', 00061 'displaytext' => 'Color Scheme', 00062 'default' => 'Light', 00063 'global' => 0 00064 ), 00065 array ( 00066 'name' => 'width', 00067 'type' => 'integer', 00068 'displaytext' => 'Width', 00069 'default' => '450', 00070 'global' => 0 00071 ), 00072 array ( 00073 'name' => 'height', 00074 'type' => 'integer', 00075 'displaytext' => 'Height', 00076 'default' => '80', 00077 'global' => 0 00078 ), 00079 array ( 00080 'name' => 'layout', 00081 'type' => 'select', 00082 'options' => 'standard|button_count', 00083 'displaytext' => 'Layout', 00084 'default' => 'standard', 00085 'global' => 0 00086 ), 00087 array ( 00088 'name' => 'noinput1', 00089 'type' => 'noinput', 00090 'displaytext' => '<b>Below is the list of options for connecting to a Facebook Page. It is recommended to set the width as 300px and height as 556px</b>', 00091 'global' => 0 00092 ), 00093 array ( 00094 'name' => 'pageurl', 00095 'type' => 'text', 00096 'displaytext' => 'Specify the Facebook pagename', 00097 'default' => '', 00098 'global' => 0 00099 ), 00100 array ( 00101 'name' => 'stream', 00102 'type' => 'select', 00103 'options' => 'Yes|No', 00104 'displaytext' => 'Show Page stream', 00105 'default' => 'Yes', 00106 'global' => 0 00107 ), 00108 array ( 00109 'name' => 'header', 00110 'type' => 'select', 00111 'options' => 'Yes|No', 00112 'displaytext' => 'Show Facebook header', 00113 'default' => 'Yes', 00114 'global' => 0 00115 ), 00116 array ( 00117 'name' => 'makeunique', 00118 'type' => 'bool', 00119 'displaytext' => 'Make the IDs unique automatically by appending a unique number ?', 00120 'default' => '1', 00121 'global' => 0 00122 ), 00123 array ( 00124 'name' => 'divclass', 00125 'type' => 'text', 00126 'displaytext' => 'DIV Class', 00127 'default' => 'fb_', 00128 'global' => 0 00129 ), 00130 array ( 00131 'name' => 'divid', 00132 'type' => 'text', 00133 'displaytext' => 'DIV ID', 00134 'default' => 'fb_', 00135 'global' => 0 00136 ), 00137 array ( 00138 'name' => 'global_disable', 00139 'type' => 'bool', 00140 'displaytext' => 'Disable News', 00141 'default' => '0', 00142 'global' => 1 00143 ), 00144 ); 00145 parent::__construct($widgetId,$widgetInstanceId,$pageId,$this->configs); 00146 00147 } 00148 00149 00150 public function initWidget() 00151 { 00152 $this->type = $this->settings['type']; 00153 $this->show_face = $this->settings['show_face']; 00154 $this->pageurl = $this->settings['pageurl']; 00155 $this->width = $this->settings['width']; 00156 $this->height = $this->settings['height']; 00157 $this->color = $this->settings['color']; 00158 $this->layout = $this->settings['layout']; 00159 $this->stream = $this->settings['stream']; 00160 $this->header = $this->settings['header']; 00161 $this->makeunique = $this->settings['makeunique']; 00162 $this->divid = $this->settings['divid']; 00163 $this->divclass = $this->settings['divclass']; 00164 $this->globaldisable = $this->settings['global_disable']; 00165 } 00166 00167 00168 public function getCommonHTML() 00169 { 00170 } 00171 public function getHTML() 00172 { 00173 global $urlRequestRoot,$cmsFolder; 00174 if($this->globaldisable=='1' || $this->globaldisable=='Yes') return ""; 00175 $ran = ''; 00176 if($this->makeunique=='1' || $this->makeunique=='Yes') 00177 $ran = $this->widgetInstanceId; 00178 $divid = $this->divid.$ran; 00179 $type = $this->type; 00180 $width = $this->width; 00181 $height = $this->height; 00182 $show_face = false; 00183 $color = $this->color; 00184 if($this->show_face=="Yes") 00185 $show_face = "true"; 00186 if($type=="Facebook Page") 00187 { 00188 $url = urlencode($this->pageurl); 00189 $stream = $header = false; 00190 if($this->stream=="Yes") 00191 $stream = "true"; 00192 if($this->header=="Yes") 00193 $header = "true"; 00194 $like = <<<FBHTML 00195 <iframe src="http://www.facebook.com/plugins/likebox.php?href=$url&width=$width&colorscheme=$color&show_faces=$show_face&stream=$stream&header=$header&height=$height" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:$width; height:$height;" allowTransparency="true"></iframe> 00196 FBHTML; 00197 } 00198 else 00199 { 00200 $layout = $this->layout; 00201 if($type=="Site") 00202 { 00203 $url = urlencode(hostURL()); 00204 $like =<<<FBHTML 00205 <iframe src="http://www.facebook.com/plugins/like.php?href=$url&layout=$layout&show_faces=$show_face&width=$width&action=like&colorscheme=$color&height=$height" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:$width; height:$height;" allowTransparency="true"></iframe> 00206 FBHTML; 00207 } 00208 else if($type=="Each Page") 00209 { 00210 $url = urlencode(selfURI()); 00211 $like =<<<FBHTML 00212 <iframe src="http://www.facebook.com/plugins/like.php?href=$url&layout=$layout&show_faces=$show_face&width=$width&action=like&colorscheme=$color&height=$height" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:$width; height:$height;" allowTransparency="true"></iframe> 00213 FBHTML; 00214 } 00215 } 00216 $fbHTML = "<div class='{$this->divclass}' id='$divid'>".$like."</div>"; 00217 return $fbHTML; 00218 } 00219 } 00220 00221 ?>