当前位置: 首页>>代码示例>>PHP>>正文


PHP SiteTree::generateURLSegment方法代码示例

本文整理汇总了PHP中SiteTree::generateURLSegment方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteTree::generateURLSegment方法的具体用法?PHP SiteTree::generateURLSegment怎么用?PHP SiteTree::generateURLSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SiteTree的用法示例。


在下文中一共展示了SiteTree::generateURLSegment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onBeforeWrite

 function onBeforeWrite()
 {
     // If there is no URLSegment set, generate one from Title
     if ((!$this->URLSegment || $this->URLSegment == 'new-offer') && $this->Title != 'New Offer') {
         $this->URLSegment = @SiteTree::generateURLSegment($this->Name);
     } else {
         if ($this->isChanged('URLSegment')) {
             // Make sure the URLSegment is valid for use in a URL
             $segment = preg_replace('/[^A-Za-z0-9]+/', '-', $this->URLSegment);
             $segment = preg_replace('/-+/', '-', $segment);
             // If after sanitising there is no URLSegment, give it a reasonable default
             if (!$segment) {
                 $segment = "Offer-{$this->ID}";
             }
             $this->URLSegment = $segment;
         }
     }
     // Ensure that this object has a non-conflicting URLSegment value.
     $count = 2;
     while ($this->LookForExistingURLSegment($this->URLSegment)) {
         $this->URLSegment = preg_replace('/-[0-9]+$/', null, $this->URLSegment) . '-' . $count;
         $count++;
     }
     parent::onBeforeWrite();
 }
开发者ID:seraphia,项目名称:donationcollector,代码行数:25,代码来源:Offer.php

示例2: onBeforeWrite

 /** 
  * Updates the group so the security section is also in sync with
  * the curent newsletters.
  */
 function onBeforeWrite()
 {
     if ($this->ID) {
         $group = $this->Group();
         if ($group->Title != "{$this->Title}") {
             $group->Title = _t('NewsletterType.MAILINGLIST', 'Mailing List:') . ' ' . $this->Title;
             // Otherwise the code would have mailing list in it too :-(
             $group->Code = SiteTree::generateURLSegment($this->Title);
             $group->write();
         }
     }
     parent::onBeforeWrite();
 }
开发者ID:ramziammar,项目名称:websites,代码行数:17,代码来源:NewsletterType.php

示例3: onBeforeWrite

 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (isset($_POST['AlbumName'])) {
         $clean_name = SiteTree::generateURLSegment($_POST['AlbumName']);
         if ($this->FolderID) {
             $this->Folder()->setName($clean_name);
             $this->Folder()->Title = $clean_name;
             $this->Folder()->write();
         } else {
             $folder = Folder::findOrMake('image-gallery/' . $this->ImageGalleryPage()->RootFolder()->Name . '/' . $clean_name);
             $this->FolderID = $folder->ID;
         }
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:15,代码来源:ImageGalleryAlbum.php

示例4: setCode

 /**
  * Overloaded to ensure the code is always descent.
  */
 public function setCode($val)
 {
     $this->setField("Code", SiteTree::generateURLSegment($val));
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:7,代码来源:Group.php


注:本文中的SiteTree::generateURLSegment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。