public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->Title) {
         $this->Title = Config::inst()->get($this->class, 'title');
     }
 }
 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] : "";
     }
 }
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->Title) {
         $this->Title = Config::inst()->get($this->class, 'title');
     }
     if (Widget::has_extension('Versioned') && Versioned::current_stage() == 'Stage') {
         $this->publishAfterWrite = true;
     }
 }
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->Sort) {
         $parentID = $this->ParentID ? $this->ParentID : 0;
         $this->Sort = DB::query("SELECT MAX(\"Sort\") + 1 FROM \"Widget\" WHERE \"ParentID\" = {$parentID}")->value();
     }
     if ($this->MoveToListID) {
         $this->ListID = $this->MoveToListID;
     }
 }