Source of file TwitterWidgetsWidget.php
Size: 1,378 Bytes - Last Modified: 2021-12-24T06:49:12+00:00
/var/www/docs.ssmods.com/process/src/code/TwitterWidgetsWidget.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | <?php class TwitterWidgetsWidget extends Widget { private static $db = array( "TwitterHTML" => "HTMLText", "Href" => "Text", "TwitterWidgetID" => "Text", ); /** * @var string */ private static $title = "Twitter"; /** * @var string */ private static $cmsTitle = "Twitter Widget"; /** * @var string */ private static $description = "Display Twitter widget on your site."; public function SmallWidget() { $result = array( "WidgetTitle" => $this->Title, "WidgetContent" => $this->WidgetContent, ); return $result; } public function getCMSFields() { $fields = parent::getCMSFields(); $fields->merge( new FieldList( new TextareaField('TwitterHTML', 'Twitter Html') ) ); return $fields; } public function onBeforeWrite() { parent::onBeforeWrite(); if ($this->TwitterHTML) { $hrefAndId = array(); preg_match_all('/<a.*href="(.+)".*data-widget-id="([0-9]*)".*>.*<\/a>/U', $this->TwitterHTML, $hrefAndId); $this->Href = isset($hrefAndId[1][0]) ? $hrefAndId[1][0] : ""; $this->TwitterWidgetID = isset($hrefAndId[2][0]) ? $hrefAndId[2][0] : ""; } } } |