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


PHP URLSegmentFilter::create方法代码示例

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


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

示例1: getCalcAssetsFolderDirectory

 /**
  * The gallery directory is created based on the page name
  * You can overwrite this behavior by extending this page
  * TODO this could also be made configurable
  * @return string
  */
 function getCalcAssetsFolderDirectory()
 {
     if ($this->ID) {
         $filter = URLSegmentFilter::create();
         return Config::inst()->get('GalleryExtension', 'gallery_folder') . '/' . $this->ID . '-' . $filter->filter($this->Title);
     }
 }
开发者ID:titledk,项目名称:silverstripe-gallery-pagetypes,代码行数:13,代码来源:GalleryPage.php

示例2: setURLSegment

 /**
  * custom setter for urlsegment
  * runs param through urlsegment filter to sanitize any unwanted characters
  * calls existsInScope for uniqueness check, otherwise appends random number until unique
  */
 function setURLSegment($value)
 {
     $urlSegment = URLSegmentFilter::create()->filter($value);
     while ($this->existsInScope($urlSegment)) {
         $urlSegment = $urlSegment . rand(1, 9);
     }
     $this->owner->setField("URLSegment", $urlSegment);
 }
开发者ID:helpfulrobot,项目名称:icecaster-urlsegmented,代码行数:13,代码来源:URLSegmented.php

示例3: onBeforeWrite

 public function onBeforeWrite()
 {
     if (!$this->URLSegment) {
         $filter = URLSegmentFilter::create();
         $this->URLSegment = $filter->filter($this->Title);
     }
     parent::onBeforeWrite();
 }
开发者ID:helpfulrobot,项目名称:plumpss-news,代码行数:8,代码来源:NewsCategory.php

示例4: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if ($this->Title) {
         $filter = URLSegmentFilter::create();
         $this->URLSegment = $filter->filter($this->Title);
         //$this->URLSegment = SiteTree::GenerateURLSegment($this->Title);
     }
 }
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-filterablearchive,代码行数:9,代码来源:FilterTag.php

示例5: generateURLSegment

 /**
  * Generate a unique URL segment based on the Member's name.
  *
  * @return string
  */
 public function generateURLSegment()
 {
     $filter = URLSegmentFilter::create();
     $name = $this->owner->FirstName . ' ' . $this->owner->Surname;
     $urlSegment = $filter->filter($name);
     if (!$urlSegment || $urlSegment == '-' || $urlSegment == '-1') {
         $urlSegment = 'profile-' . $this->owner->ID;
     }
     return $urlSegment;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-blog,代码行数:15,代码来源:BlogMemberExtension.php

示例6: generateURLSegment

 private function generateURLSegment($title)
 {
     $filter = URLSegmentFilter::create();
     $t = $filter->filter($title);
     // Fallback to generic page name if path is empty (= no valid, convertable characters)
     if (!$t || $t == '-' || $t == '-1') {
         $t = "page-{$this->ID}";
     }
     return $t;
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:10,代码来源:VideoPresentation.php

示例7: generateURLSegment

 /**
  * Generate a URL segment based on the title provided.
  *
  * If {@link Extension}s wish to alter URL segment generation, they can do so by defining
  * updateURLSegment(&$url, $title).  $url will be passed by reference and should be modified.
  * $title will contain the title that was originally used as the source of this generated URL.
  * This lets extensions either start from scratch, or incrementally modify the generated URL.
  *
  * @param string $title the given title
  * @return string generated url segment
  */
 public function generateURLSegment($title)
 {
     $filter = URLSegmentFilter::create();
     $t = $filter->filter($title);
     // Fallback to generic page name if path is empty (= no valid, convertable characters)
     if (!$t || $t == '-' || $t == '-1') {
         $t = $this->fallbackUrl();
     }
     // Hook for extensions
     $this->owner->extend('updateURLSegment', $t, $title);
     return $t;
 }
开发者ID:helpfulrobot,项目名称:ntb-silverstripe-rest-api,代码行数:23,代码来源:SlugableExtension.php

示例8: generateSlug

 public function generateSlug($title, $allowExtension = true)
 {
     $t = \URLSegmentFilter::create()->filter($title);
     // Fallback to generic page name if path is empty (= no valid, convertable characters)
     if (!$t || $t == '-' || $t == '-1') {
         $t = "menu-{$this->ID}";
     }
     // Hook for extensions
     if ($allowExtension) {
         $this->extend('updateSlug', $t, $title);
     }
     return $t;
 }
开发者ID:milkyway-multimedia,项目名称:ss-linkable-menus,代码行数:13,代码来源:LinkableMenu.php

示例9: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if ($this->isChanged('URLSegment')) {
         $this->URLSegment = URLSegmentFilter::create()->filter($this->URLSegment);
     }
     if (!$this->URLSegment) {
         $this->URLSegment = URLSegmentFilter::create()->filter($this->Title);
     }
     if (!$this->URLSegment) {
         $this->URLSegment = 'main';
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-frontend-dashboards,代码行数:13,代码来源:DashboardPage.php

示例10: updateURLSegment

 public function updateURLSegment(&$t, $title)
 {
     $filter = URLSegmentFilter::create();
     // use default transliterator
     $title = $filter->getTransliterator()->toASCII($title);
     // set cyrillic transliterator
     $filter->setTransliterator(CyrillicTransliterator::create());
     $t = $filter->filter($title);
     // Fallback to generic page name if path is empty (= no valid, convertable characters)
     if (!$t || $t == '-' || $t == '-1') {
         $t = "page-" . $this->owner->ID;
     }
 }
开发者ID:helpfulrobot,项目名称:unisolutions-silverstripe-cyrillic-transliterator,代码行数:13,代码来源:CyrillicURLSegmentExtension.php

示例11: generateURLSegment

 /**
  * Generate a URL segment based on the title provided.
  * 
  * @param string $title Page title.
  * @return string Generated url segment
  */
 protected function generateURLSegment($title)
 {
     $filter = URLSegmentFilter::create();
     $t = $filter->filter($title);
     // Fallback to generic name if path is empty (= no valid, convertable characters)
     if (!$t || $t == '-' || $t == '-1') {
         $t = "{$this->owner->ClassName}-{$this->owner->ID}";
     } else {
         // Make sure that it does not already exists for another object
         $class = $this->owner->ClassName;
         $obj = $class::get()->filter(array("URLSegment" => $t))->exclude(array("ID" => $this->owner->ID))->first();
         if ($obj) {
             $t .= "-{$this->owner->ID}";
         }
     }
     return $t;
 }
开发者ID:helpfulrobot,项目名称:linkdup-silverstripe-seofriendlydataobject,代码行数:23,代码来源:SeoFriendlyDataObject.php

示例12: onBeforeWrite

 /**
  * Based on the title of product it generates a URLSegment for it
  * so that SEO friendly Product pages can be generated.
  *
  * Credit: https://gist.github.com/Zauberfisch/9460395
  *
  * @return string URLSegment /product-title-x-y-z/
  */
 protected function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->ProductDescription) {
         $this->ProductDescription = $this->ProductDescription;
     }
     $filter = URLSegmentFilter::create();
     if (!$this->URLSegment) {
         $this->URLSegment = $this->ProductDescription;
     }
     $this->URLSegment = $filter->filter($this->URLSegment);
     if (!$this->URLSegment) {
         $this->URLSegment = uniqid();
     }
     $count = 2;
     while (static::get_by_url_segment($this->URLSegment, $this->ID)) {
         // add a -n to the URLSegment if it already existed
         $this->URLSegment = preg_replace('/-[0-9]+$/', null, $this->URLSegment) . '-' . $count;
         $count++;
     }
 }
开发者ID:shoaibali,项目名称:silverstripe-shop-lite,代码行数:29,代码来源:Products.php

示例13: generateURLSegment

 /**
  * COPIED FROM SITETREE
  *
  * Generate a URL segment based on the title provided.
  * 
  * @param string $title Product title
  * @return string Generated url segment
  */
 public function generateURLSegment($title)
 {
     $filter = URLSegmentFilter::create();
     $t = $filter->filter($title);
     // Fallback to generic page name if path is empty (= no valid, convertable characters)
     if (!$t || $t == '-' || $t == '-1') {
         $t = "page-{$this->ID}";
     }
     // Hook for extensions
     $this->extend('updateURLSegment', $t, $title);
     // Check to see if URLSegment exists already, if it does, append -* where * is COUNT()+1
     $seg = new SQLQuery('COUNT(*)');
     $seg->setFrom(get_class($this))->addWhere("`URLSegment` LIKE '%{$t}%'");
     $count = $seg->execute()->value();
     if ($count > 0) {
         $count++;
         return $t . "-" . $count;
     } else {
         return $t;
     }
 }
开发者ID:micschk,项目名称:torindul-silverstripe-shop,代码行数:29,代码来源:Product_Categories.php

示例14: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $classname = strtolower($this->owner->ClassName);
     $filter = URLSegmentFilter::create();
     if ((!$this->owner->URLSegment || $this->owner->URLSegment == 'new-' . $classname) && $this->owner->Title != 'New ' . $classname) {
         $this->owner->URLSegment = $filter->filter($this->owner->Title);
     } else {
         if ($this->owner->isChanged('URLSegment')) {
             $segment = preg_replace('/[^A-Za-z0-9]+/', '-', $this->owner->URLSegment);
             $segment = preg_replace('/-+/', '-', $segment);
             if (!$segment) {
                 $segment = $classname . "-" . $this->owner->ID;
             }
             $this->owner->URLSegment = $segment;
         }
     }
     $count = 2;
     while ($this->LookForExistingURLSegment($this->owner->URLSegment)) {
         $this->owner->URLSegment = preg_replace('/-[0-9]+$/', null, $this->owner->URLSegment) . '-' . $count;
         $count++;
     }
 }
开发者ID:KINKCreative,项目名称:actors,代码行数:23,代码来源:URLSegmentDecorator.php

示例15: raw2url

 /**
  * Convert a string (normally a title) to a string suitable for using in
  * urls and other html attributes. Uses {@link URLSegmentFilter}.
  *
  * @param string 
  * @return string
  */
 public static function raw2url($title)
 {
     $f = URLSegmentFilter::create();
     return $f->filter($title);
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:12,代码来源:Convert.php


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