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


PHP Convert::raw2url方法代码示例

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


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

示例1: Field

 /**
  * Method that turns this object into a field type, to be loaded into a form
  *
  * @return FormField
  */
 public function Field()
 {
     if ($this->Title && $this->DisplayAs) {
         $name = "customise_{$this->ID}_" . Convert::raw2url($this->Title);
         $title = $this->Required ? $this->Title . ' *' : $this->Title;
         $options = $this->Options()->map('Title', 'ItemSummary');
         $defaults = $this->DefaultOptions();
         $default = $defaults->exists() ? $defaults->first()->Title : null;
         switch ($this->DisplayAs) {
             case 'Dropdown':
                 $field = DropdownField::create($name, $title, $options, $default)->setEmptyString(_t('Commerce.PleaseSelect', 'Please Select'))->setAttribute("class", "dropdown btn");
                 break;
             case 'Radio':
                 $field = OptionSetField::create($name, $title, $options, $default);
                 break;
             case 'Checkboxes':
                 $field = CheckboxSetField::create($name, $title, $options, $defaults->column('ID'));
                 break;
             case 'TextEntry':
                 $field = TextField::create($name, $title);
                 if ($this->MaxLength) {
                     $field->setMaxLength($this->MaxLength);
                 }
                 break;
         }
         $this->extend('updateField', $field);
         return $field;
     } else {
         return false;
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:36,代码来源:ProductCustomisation.php

示例2: processRecord

 public function processRecord($record, $columnMap, &$results, $preview = false)
 {
     $objID = parent::processRecord($record, $columnMap, $results, $preview);
     $_cache_groupByCode = array();
     // Add to predefined groups
     $member = DataObject::get_by_id($this->objectClass, $objID);
     foreach ($this->groups as $group) {
         // TODO This isnt the most memory effective way to add members to a group
         $member->Groups()->add($group);
     }
     // Add to groups defined in CSV
     if (isset($record['Groups']) && $record['Groups']) {
         $groupCodes = explode(',', $record['Groups']);
         foreach ($groupCodes as $groupCode) {
             $groupCode = Convert::raw2url($groupCode);
             if (!isset($_cache_groupByCode[$groupCode])) {
                 $group = Group::get()->filter('Code', $groupCode)->first();
                 if (!$group) {
                     $group = new Group();
                     $group->Code = $groupCode;
                     $group->Title = $groupCode;
                     $group->write();
                 }
                 $member->Groups()->add($group);
                 $_cache_groupByCode[$groupCode] = $group;
             }
         }
     }
     $member->destroy();
     unset($member);
     return $objID;
 }
开发者ID:XDdesigners,项目名称:silverstripe-framework,代码行数:32,代码来源:MemberCsvBulkLoader.php

示例3: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     // If subsites enabled
     if (class_exists('Subsite') && ($subsite = Subsite::currentSubsite())) {
         $this->SubsiteID = $subsite->ID;
     }
     // Ensure the slug is URL safe
     $this->Slug = $this->Slug ? Convert::raw2url($this->Slug) : Convert::raw2url($this->Title);
 }
开发者ID:henrypenny,项目名称:silverstripe-custommenus,代码行数:10,代码来源:CustomMenuHolder.php

示例4: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $this->CallBackSlug = !$this->CallBackSlug ? 'sagepay' : Convert::raw2url($this->CallBackSlug);
     if (!$this->Summary) {
         $this->Summary = "Pay with credit/debit card securely via SagePay";
     }
     if (!$this->GatewayMessage) {
         $this->GatewayMessage = "Thank you for your order from: " . SiteConfig::current_site_config()->Title;
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:11,代码来源:SagePay.php

示例5: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     // Set our URL segment
     if (!$this->URLSegment) {
         $url = Convert::raw2url($this->Title);
         $url = str_replace(":", "", $url);
         $url = str_replace(";", "", $url);
         $this->URLSegment = $url;
     }
 }
开发者ID:i-lateral,项目名称:silverstripe-filterable,代码行数:11,代码来源:FilterOption.php

示例6: onBeforeWrite

 public function onBeforeWrite()
 {
     if ($this->owner->ProductGroupID) {
         $group = $this->owner->ProductGroup();
         // Set the URL for this product to include the parent URL
         $this->owner->URLSegment = $group->URLSegment . "-" . Convert::raw2url($this->owner->Title);
         // Set the base price
         if (!$this->owner->BasePrice) {
             $this->owner->BasePrice = $group->BasePrice;
         }
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce-groupedproduct,代码行数:12,代码来源:GroupedProduct_CatalogueProduct.php

示例7: TagsCollection

 /**
  * Returns the tags added to this discussion
  */
 public function TagsCollection()
 {
     $output = new ArrayList();
     if ($this->Tags) {
         $tags = preg_split(" *, *", trim($this->Tags));
         $link = $this->Parent() ? $this->Parent()->Link('tag') : '';
         foreach ($tags as $tag) {
             $output->push(new ArrayData(array('Tag' => Convert::raw2xml($tag), 'Link' => Controller::join_links($link, Convert::raw2url($tag)), 'URLTag' => Convert::raw2url($tag))));
         }
     }
     return $output;
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-discussions,代码行数:15,代码来源:Discussion.php

示例8: getTagsCollection

 public function getTagsCollection()
 {
     $allTags = new ArrayList();
     $max = 0;
     $member = Member::currentUser();
     // Find if we need to filter tags by current discussion page
     $controller = Controller::curr();
     if (method_exists($controller, "data")) {
         $page = $controller->data();
     } else {
         $page = null;
     }
     if ($page != null && $page instanceof DiscussionPage) {
         $discussions = $page->Discussions();
     } else {
         $discussions = Discussion::get();
     }
     if ($discussions) {
         foreach ($discussions as $discussion) {
             if ($discussion->canView($member)) {
                 $theseTags = preg_split(" *, *", trim($discussion->Tags));
                 foreach ($theseTags as $tag) {
                     if ($tag) {
                         if ($allTags->find("Tag", $tag)) {
                             $allTags->find("Tag", $tag)->Count++;
                         } else {
                             $allTags->push(new ArrayData(array("Tag" => $tag, "Count" => 1, "Link" => Controller::join_links($discussion->Parent()->Link("tag"), Convert::raw2url($tag)))));
                         }
                         $tag_count = $allTags->find("Tag", $tag)->Count;
                         $max = $tag_count > $max ? $tag_count : $max;
                     }
                 }
             }
         }
         if ($allTags->exists()) {
             // First sort our tags
             $allTags->sort($this->SortParam, $this->SortOrder);
             // Now if a limit has been set, limit the list
             if ($this->Limit) {
                 $allTags = $allTags->limit($this->Limit);
             }
         }
         return $allTags;
     }
     return;
 }
开发者ID:i-lateral,项目名称:silverstripe-discussions,代码行数:46,代码来源:DiscussionsTagsWidget.php

示例9: searchTweets

 public function searchTweets($query, $count)
 {
     // Init caching
     $cacheKey = "searchTweets_" . str_replace("-", "_", Convert::raw2url($query)) . "_{$count}";
     $cache = SS_Cache::factory('CachedTwitterService');
     // Return cached value, if available
     if ($rawResult = $cache->load($cacheKey)) {
         return unserialize($rawResult);
     }
     // Save and return
     $result = $this->cachedService->searchTweets($query, $count);
     $cache->save(serialize($result), $cacheKey, array(), Config::inst()->get('CachedTwitterService', 'lifetime'));
     // Refresh the 'TimeAgo' field, as the cached value would now be outdated, or the locale could have changed.
     if ($result) {
         foreach ($result as $index => $item) {
             $result[$index]['TimeAgo'] = TwitterService::determine_time_ago($item['Date']);
         }
     }
     return $result;
 }
开发者ID:tractorcow,项目名称:silverstripe-twitter,代码行数:20,代码来源:CachedTwitterService.php

示例10: bulkimport

 function bulkimport($data, $form)
 {
     $fh = fopen($data['SourceFile']['tmp_name'], 'r');
     Versioned::reading_stage('Stage');
     if (isset($data['DeleteExisting']) && $data['DeleteExisting']) {
         foreach (Page::get() as $page) {
             $page->deleteFromStage('Stage');
             $page->deleteFromStage('Live');
         }
     }
     $parentRefs = array();
     while ($line = fgets($fh, 10000)) {
         // Skip comments
         if (preg_match('/^#/', $line)) {
             continue;
         }
         // Split up indentation, title and optional JSON
         if (preg_match("/^(\t*)([^{]*)({.*})?/", $line, $matches)) {
             $numTabs = strlen($matches[1]);
             $title = trim($matches[2]);
             $json = isset($matches[3]) && trim($matches[3]) ? json_decode(trim($matches[3]), true) : array();
             // Either extract the URL from provided meta data, or generate it
             $url = array_key_exists('URLSegment', $json) ? $json['URLSegment'] : $title;
             $url = Convert::raw2url($url);
             // Allow custom classes based on meta data
             $className = array_key_exists('ClassName', $json) ? $json['ClassName'] : 'Page';
             // If we've got too many tabs, then outdent until we find a page to attach to.
             while (!isset($parentRefs[$numTabs - 1]) && $numTabs > 0) {
                 $numTabs--;
             }
             $parentID = $numTabs > 0 ? $parentRefs[$numTabs - 1] : 0;
             // Try to find an existing page, or create a new one
             $page = Page::get()->filter(array('URLSegment' => $url, 'ParentID' => $parentID))->First();
             if (!$page) {
                 $page = new $className();
             }
             // Apply any meta data properties to the page
             $page->ParentID = $parentID;
             $page->Title = $title;
             $page->URLSegment = $url;
             if ($json) {
                 $page->update($json);
             }
             $page->write();
             // Optionall publish
             if (isset($data['PublishAll']) && $data['PublishAll']) {
                 $page->publish('Stage', 'Live');
             }
             if (!SapphireTest::is_running_test()) {
                 echo "<li>Written ID# {$page->ID}: {$page->Title}";
                 if ($page->ParentID) {
                     echo " (ParentID# {$page->ParentID})";
                 }
                 echo "</li>";
             }
             // Populate parentRefs with the most recent page at every level.   Necessary to build tree
             // Children of home should be placed at the top level
             if (strtolower($title) == 'home') {
                 $parentRefs[$numTabs] = 0;
             } else {
                 $parentRefs[$numTabs] = $page->ID;
             }
             // Remove no-longer-relevant children from the parentRefs.  Allows more graceful acceptance of files
             // with errors
             for ($i = sizeof($parentRefs) - 1; $i > $numTabs; $i--) {
                 unset($parentRefs[$i]);
             }
             // Memory cleanup
             $page->destroy();
             unset($page);
         }
     }
     if (!SapphireTest::is_running_test()) {
         $complete = $this->complete();
         echo $complete['Content'];
     } else {
         $this->redirect($this->Link() . 'complete');
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-sitetreeimporter,代码行数:79,代码来源:SiteTreeImporter.php

示例11: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $this->URLSegment = $this->URLSegment ? $this->URLSegment : Convert::raw2url($this->Title);
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-discussions,代码行数:5,代码来源:DiscussionCategory.php

示例12: testRaw2URL

 /**
  * Tests {@link Convert::testRaw2URL()}
  * @todo test toASCII()
  */
 public function testRaw2URL()
 {
     $orig = Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte');
     Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', false);
     $this->assertEquals('foo', Convert::raw2url('foo'));
     $this->assertEquals('foo-and-bar', Convert::raw2url('foo & bar'));
     $this->assertEquals('foo-and-bar', Convert::raw2url('foo &amp; bar!'));
     $this->assertEquals('foos-bar-2', Convert::raw2url('foo\'s [bar] (2)'));
     Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', $orig);
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:14,代码来源:ConvertTest.php

示例13: setCode

 /**
  * Overloaded to ensure the code is always descent.
  *
  * @param string
  */
 public function setCode($val)
 {
     $this->setField("Code", Convert::raw2url($val));
 }
开发者ID:spekulatius,项目名称:silverstripe-framework,代码行数:9,代码来源:Group.php

示例14: parseText

 /**
  * Parse the tweet object into a HTML block
  * 
  * @param stdObject $tweet Tweet object
  * @return string HTML text
  */
 protected function parseText($tweet)
 {
     $rawText = $tweet->text;
     // tokenise into words for parsing (multibyte safe)
     $tokens = preg_split('/(?<!^)(?!$)/u', $rawText);
     // Inject links
     foreach ($tweet->entities->urls as $url) {
         $this->injectLink($tokens, $url, $url->url, $url->expanded_url);
     }
     // Inject hashtags
     foreach ($tweet->entities->hashtags as $hashtag) {
         $link = 'https://twitter.com/search?src=hash&q=' . Convert::raw2url('#' . $hashtag->text);
         $text = "#" . $hashtag->text;
         $this->injectLink($tokens, $hashtag, $link, $text);
     }
     // Inject mentions
     foreach ($tweet->entities->user_mentions as $mention) {
         $link = 'https://twitter.com/' . Convert::raw2url($mention->screen_name);
         $this->injectLink($tokens, $mention, $link, $mention->name);
     }
     // Re-combine tokens
     return implode('', $tokens);
 }
开发者ID:helpfulrobot,项目名称:cbarberis-twitter,代码行数:29,代码来源:TwitterService.php

示例15: testRaw2URL

	/**
	 * @todo test toASCII()
	 */
	function testRaw2URL() {
		$this->assertEquals('foo', Convert::raw2url('foo'));
		$this->assertEquals('foo-and-bar', Convert::raw2url('foo & bar'));
		$this->assertEquals('foo-and-bar', Convert::raw2url('foo &amp; bar!'));
		$this->assertEquals('foos-bar-2', Convert::raw2url('foo\'s [bar] (2)'));
	}
开发者ID:redema,项目名称:sapphire,代码行数:9,代码来源:ConvertTest.php


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