コード例 #1
0
 /**
  * Setup the URLSegment for this item and create a Renamed Object if it's a rename-action.
  */
 private function setURLValue()
 {
     if (!$this->URLSegment || $this->isChanged('Title') && !$this->isChanged('URLSegment')) {
         if ($this->ID > 0) {
             $Renamed = new Renamed();
             $Renamed->OldLink = $this->URLSegment;
             $Renamed->NewsID = $this->ID;
             $Renamed->write();
         }
         $this->URLSegment = singleton('SiteTree')->generateURLSegment($this->Title);
         if (strpos($this->URLSegment, 'page-') === false) {
             $nr = 1;
             $URLSegment = $this->URLSegment;
             while ($this->LookForExistingURLSegment($URLSegment)) {
                 $URLSegment = $this->URLSegment . '-' . $nr++;
             }
             $this->URLSegment = $URLSegment;
         }
     }
 }