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


PHP Text::setValue方法代码示例

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


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

示例1: testContentLinkInjections

 function testContentLinkInjections()
 {
     $field = new Text();
     // External links injection.
     $field->setValue('<a href="http://newzealand.govt.nz">New Zealand Government</a>');
     $this->assertEquals($field->RichLinks(), '<a class="external" rel="external" title="Open external link" href="http://newzealand.govt.nz">New Zealand Government ' . '<span class="nonvisual-indicator">(external link)</span> </a>', 'Injects attributes to external link without target.');
     $field->setValue('<a href="http://newzealand.govt.nz" target="_blank">New Zealand Government</a>');
     $this->assertEquals($field->RichLinks(), '<a class="external" rel="external" title="Open external link" href="http://newzealand.govt.nz" target="_blank">New Zealand Government ' . '<span class="nonvisual-indicator">(external link)</span> </a>', 'Injects attributes to external link with target, while keeping the existing attributes.');
     // Check the normal links are not affected.
     $field->setValue('<a href="[sitetree_link,id=1]">Internal</a>');
     $this->assertEquals($field->RichLinks(), '<a href="[sitetree_link,id=1]">Internal</a>', 'Regular link is not modified.');
 }
开发者ID:helpfulrobot,项目名称:silverstripe-standardsediting,代码行数:12,代码来源:RichLinksExtensionTest.php

示例2: setValue

 /**
  *
  * @param string $value Date in format YYYY-MM-DD
  * @return type
  * @throws \Exception
  */
 public function setValue($value)
 {
     if (empty($value)) {
         return;
     }
     /**
      * Below deals with an integer and tries to identify if it is a timestamp
      * or date formatted.
      */
     if (is_int($value)) {
         $value = 333923;
         $date_string_test = strftime('%Y%m%d', $value);
         if ($date_string_test < 19700101) {
             $date_string_test2 = strftime('%Y%m%d', strtotime($value));
             if ($date_string_test2 < 19700101) {
                 throw new \Exception('Bad integer value sent to Form\\Input\\Date');
             } else {
                 $value = strftime('%Y-%m-%d', strtotime($value));
             }
         } else {
             $value = strftime('%Y-%m-%d', $value);
         }
     }
     if (!preg_match('/\\d{4}-\\d{2}-\\d{2}/', $value)) {
         throw new \Exception(t('Date format is YYYY-MM-DD: %s', $value));
     }
     parent::setValue($value);
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:34,代码来源:Date.php

示例3: RSSItems

 /**
  * Gets a list of all the items in the RSS feed given a user-provided URL, limit, and date format
  *
  * @return ArrayList
  */
 public function RSSItems()
 {
     if (!$this->FeedURL) {
         return false;
     }
     $doc = new DOMDocument();
     @$doc->load($this->FeedURL);
     $items = $doc->getElementsByTagName('item');
     $feeds = array();
     foreach ($items as $node) {
         $itemRSS = array('title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue);
         $feeds[] = $itemRSS;
     }
     $output = ArrayList::create(array());
     $count = 0;
     foreach ($feeds as $item) {
         if ($count >= $this->Count) {
             break;
         }
         // Cast the Date
         $date = new Date('Date');
         $date->setValue($item['date']);
         // Cast the Title
         $title = new Text('Title');
         $title->setValue($item['title']);
         $output->push(new ArrayData(array('Title' => $title, 'Date' => $date->Format($this->DateFormat), 'Link' => $item['link'])));
         $count++;
     }
     return $output;
 }
开发者ID:helpfulrobot,项目名称:unclecheese-dashboard,代码行数:35,代码来源:DashboardRSSFeedPanel.php

示例4: setValue

 public function setValue($value)
 {
     if ($value && !preg_match("@^(https?|ftp)://@", $value)) {
         $value = "http://{$value}";
     }
     return parent::setValue($value);
 }
开发者ID:monomelodies,项目名称:formulaic,代码行数:7,代码来源:Url.php

示例5: setValue

 public function setValue($value, $record = null)
 {
     if (!is_string($value)) {
         $value = json_encode($value);
     }
     return parent::setValue($value, $record);
 }
开发者ID:lekoala,项目名称:silverstripe-form-extras,代码行数:7,代码来源:DBLargeJsonField.php

示例6: FeedItems

	function FeedItems() {
		$output = new DataObjectSet();
		
		include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
		
		$t1 = microtime(true);
		$this->feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
		$this->feed->init();
		if($items = $this->feed->get_items(0, $this->NumberToShow)) {
			foreach($items as $item) {
				
				// Cast the Date
				$date = new Date('Date');
				$date->setValue($item->get_date());

				// Cast the Title
				$title = new Text('Title');
				$title->setValue($item->get_title());

				$output->push(new ArrayData(array(
					'Title' => $title,
					'Date' => $date,
					'Link' => $item->get_link()
				)));
			}
			return $output;
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:28,代码来源:RSSWidget.php

示例7: testLimitWordCountXML

 /**
  * Test {@link Text->LimitWordCountXML()}
  */
 function testLimitWordCountXML()
 {
     $cases = array('<p>Stuff & stuff</p>' => 'Stuff &amp;...', "Stuff\nBlah Blah Blah" => "Stuff<br />Blah Blah...", "Stuff<Blah Blah" => "Stuff&lt;Blah Blah", "Stuff>Blah Blah" => "Stuff&gt;Blah Blah");
     foreach ($cases as $originalValue => $expectedValue) {
         $textObj = new Text('Test');
         $textObj->setValue($originalValue);
         $this->assertEquals($expectedValue, $textObj->LimitWordCountXML(3));
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:12,代码来源:TextTest.php

示例8: setValue

 public function setValue($value)
 {
     if (is_int($value)) {
         $value = date($this->format, $value);
     } elseif ($time = strtotime($value)) {
         $value = date($this->format, $time);
     }
     return parent::setValue($value);
 }
开发者ID:monomelodies,项目名称:formulaic,代码行数:9,代码来源:Datetime.php

示例9: testLimitSentences

 /**
  * Test {@link Text->LimitSentences()}
  */
 public function testLimitSentences()
 {
     $cases = array('' => '', 'First sentence.' => 'First sentence.', 'First sentence. Second sentence' => 'First sentence. Second sentence.', '<p>First sentence.</p>' => 'First sentence.', '<p>First sentence. Second sentence. Third sentence</p>' => 'First sentence. Second sentence.', '<p>First sentence. <em>Second sentence</em>. Third sentence</p>' => 'First sentence. Second sentence.', '<p>First sentence. <em class="dummyClass">Second sentence</em>. Third sentence</p>' => 'First sentence. Second sentence.');
     foreach ($cases as $originalValue => $expectedValue) {
         $textObj = new Text('Test');
         $textObj->setValue($originalValue);
         $this->assertEquals($expectedValue, $textObj->LimitSentences(2));
     }
 }
开发者ID:normann,项目名称:sapphire,代码行数:12,代码来源:TextTest.php

示例10: setValue

 public function setValue($value)
 {
     if (!is_null($value)) {
         $tmp = preg_replace('/[^\\d]/', '', $value);
         if (strlen($tmp)) {
             $value = $tmp;
             if ($value[0] != '0') {
                 $value = "0{$value}";
             }
         }
     }
     return parent::setValue($value);
 }
开发者ID:monomelodies,项目名称:formulaic,代码行数:13,代码来源:Tel.php

示例11: Breadcrumbs

 /**
  * Adds the part for 'download search' to the breadcrumbs. Sets the link for
  * The default action in breadcrumbs.
  *
  * @param int  $maxDepth       maximum levels
  * @param bool $unlinked       link breadcrumbs elements
  * @param bool $stopAtPageType name of PageType to stop at
  * @param bool $showHidden     show pages that will not show in menus
  * 
  * @return string
  * 
  * @author Sebastian Diel <sdiel@pixeltricks.de>
  * @since 27.06.2011
  */
 public function Breadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false)
 {
     $page = $this;
     $pages = array();
     while ($page && (!$maxDepth || count($pages) < $maxDepth) && (!$stopAtPageType || $page->ClassName != $stopAtPageType)) {
         if ($showHidden || $page->ShowInMenus || $page->ID == $this->ID) {
             $pages[] = $page;
         }
         $page = $page->Parent;
     }
     if (Controller::curr()->getAction() == 'results') {
         $title = new Text();
         $title->setValue(_t('SilvercartDownloadPageHolder.SearchResults'));
         array_unshift($pages, new ArrayData(array('MenuTitle' => $title, 'Title' => $title, 'Link' => '')));
     }
     $template = new SSViewer('BreadcrumbsTemplate');
     return $template->process($this->customise(new ArrayData(array('Pages' => new ArrayList(array_reverse($pages))))));
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:32,代码来源:SilvercartDownloadPageHolder.php

示例12: setValue

 /**
  * Overload set value
  *
  * @param mixed $value
  * @return $this
  */
 public function setValue($value)
 {
     if (!empty($value)) {
         try {
             $date = substr($value, 0, strlen(date($this->getFormatDisplay())));
             $value = \Carbon\Carbon::createFromFormat($this->getFormatDisplay(), $date);
         } catch (\InvalidArgumentException $e) {
             try {
                 $date = substr($value, 0, strlen(date($this->getFormatStore())));
                 $value = \Carbon\Carbon::createFromFormat($this->getFormatStore(), $date);
             } catch (\InvalidArgumentException $e) {
                 throw $e;
             }
         } finally {
             $value = $value instanceof \Carbon\Carbon ? $value->format($this->getFormatStore()) : '';
         }
     }
     return parent::setValue($value);
 }
开发者ID:frenchfrogs,项目名称:framework,代码行数:25,代码来源:Date.php

示例13: results

 /**
  * Overrides the ContentControllerSearchExtension and adds snippets to results.
  */
 function results($data, $form, $request)
 {
     $this->linkToAllSiteRSSFeed();
     $results = $form->getResults();
     $query = $form->getSearchQuery();
     // Add context summaries based on the queries.
     foreach ($results as $result) {
         $contextualTitle = new Text();
         $contextualTitle->setValue($result->MenuTitle ? $result->MenuTitle : $result->Title);
         $result->ContextualTitle = $contextualTitle->ContextSummary(300, $query);
         if (!$result->Content && $result->ClassName == 'File') {
             // Fake some content for the files.
             $result->ContextualContent = "A file named \"{$result->Name}\" ({$result->Size}).";
         } else {
             $result->ContextualContent = $result->obj('Content')->ContextSummary(300, $query);
         }
     }
     $rssLink = HTTP::setGetVar('rss', '1');
     // Render the result.
     $data = array('Results' => $results, 'Query' => $query, 'Title' => _t('SearchForm.SearchResults', 'Search Results'), 'RSSLink' => $rssLink);
     // Choose the delivery method - rss or html.
     if (!$this->owner->request->getVar('rss')) {
         // Add RSS feed to normal search.
         RSSFeed::linkToFeed($rssLink, "Search results for query \"{$query}\".");
         return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
     } else {
         // De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context.
         $fullList = $results->getList()->sort('LastEdited', 'DESC');
         // Get some descriptive strings
         $siteName = SiteConfig::current_site_config()->Title;
         $siteTagline = SiteConfig::current_site_config()->Tagline;
         if ($siteName) {
             $title = "{$siteName} search results for query \"{$query}\".";
         } else {
             $title = "Search results for query \"{$query}\".";
         }
         // Generate the feed content.
         $rss = new RSSFeed($fullList, $this->owner->request->getURL(), $title, $siteTagline, "Title", "ContextualContent", null);
         $rss->setTemplate('Page_results_rss');
         return $rss->outputToBrowser();
     }
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-express,代码行数:45,代码来源:ExpressHomePage.php

示例14: FeedItems

 function FeedItems()
 {
     $output = new DataObjectSet();
     // Protection against infinite loops when an RSS widget pointing to this page is added to this page
     if (stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) {
         return $output;
     }
     include_once Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/simplepie.inc');
     $t1 = microtime(true);
     $feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
     $feed->init();
     if ($items = $feed->get_items(0, $this->NumberToShow)) {
         foreach ($items as $item) {
             // Cast the Date
             $date = new Date('Date');
             $date->setValue($item->get_date());
             // Cast the Title
             $title = new Text('Title');
             $title->setValue($item->get_title());
             $output->push(new ArrayData(array('Title' => $title, 'Date' => $date, 'Link' => $item->get_link())));
         }
         return $output;
     }
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:24,代码来源:RSSWidget.php

示例15: testHasValue

 function testHasValue()
 {
     $varcharField = new Varchar("testfield");
     $this->assertTrue($varcharField->getNullifyEmpty());
     $varcharField->setValue('abc');
     $this->assertTrue($varcharField->hasValue());
     $varcharField->setValue('');
     $this->assertFalse($varcharField->hasValue());
     $varcharField->setValue(null);
     $this->assertFalse($varcharField->hasValue());
     $varcharField = new Varchar("testfield", 50, array('nullifyEmpty' => false));
     $this->assertFalse($varcharField->getNullifyEmpty());
     $varcharField->setValue('abc');
     $this->assertTrue($varcharField->hasValue());
     $varcharField->setValue('');
     $this->assertTrue($varcharField->hasValue());
     $varcharField->setValue(null);
     $this->assertFalse($varcharField->hasValue());
     $textField = new Text("testfield");
     $this->assertTrue($textField->getNullifyEmpty());
     $textField->setValue('abc');
     $this->assertTrue($textField->hasValue());
     $textField->setValue('');
     $this->assertFalse($textField->hasValue());
     $textField->setValue(null);
     $this->assertFalse($textField->hasValue());
     $textField = new Text("testfield", array('nullifyEmpty' => false));
     $this->assertFalse($textField->getNullifyEmpty());
     $textField->setValue('abc');
     $this->assertTrue($textField->hasValue());
     $textField->setValue('');
     $this->assertTrue($textField->hasValue());
     $textField->setValue(null);
     $this->assertFalse($textField->hasValue());
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:35,代码来源:DBFieldTest.php


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