當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。