本文整理汇总了PHP中HtmlEditorField::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlEditorField::setValue方法的具体用法?PHP HtmlEditorField::setValue怎么用?PHP HtmlEditorField::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlEditorField
的用法示例。
在下文中一共展示了HtmlEditorField::setValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBrokenLinkHighlighting
public function testBrokenLinkHighlighting()
{
$sitetree = new SiteTree();
$editor = new HtmlEditorField('Content');
$editor->setValue('<a href="[sitetree_link id=0]">Broken Link</a>');
$element = new SimpleXMLElement(html_entity_decode((string) new SimpleXMLElement($editor->Field())));
$this->assertContains('ss-broken', (string) $element['class'], 'A broken link class is added to broken links');
$editor->setValue(sprintf('<a href="[sitetree_link id=%d]">Working Link</a>', $this->idFromFixture('SiteTree', 'home')));
$element = new SimpleXMLElement(html_entity_decode((string) new SimpleXMLElement($editor->Field())));
$this->assertNotContains('ss-broken', (string) $element['class']);
}
示例2: testSavingLinksWithoutHref
public function testSavingLinksWithoutHref()
{
$obj = $this->objFromFixture('HtmlEditorFieldTest_Object', 'home');
$editor = new HtmlEditorField('Content');
$editor->setValue('<p><a name="example-anchor"></a></p>');
$editor->saveInto($obj);
$this->assertEquals('<p><a name="example-anchor"></a></p>', $obj->Content, 'Saving a link without a href attribute works');
}
示例3: buildbrokenlinks
public function buildbrokenlinks($request)
{
// Protect against CSRF on destructive action
if (!SecurityToken::inst()->checkRequest($request)) {
return $this->httpError(400);
}
increase_time_limit_to();
increase_memory_limit_to();
if ($this->urlParams['ID']) {
$newPageSet[] = DataObject::get_by_id("Page", $this->urlParams['ID']);
} else {
$pages = DataObject::get("Page");
foreach ($pages as $page) {
$newPageSet[] = $page;
}
$pages = null;
}
$content = new HtmlEditorField('Content');
$download = new HtmlEditorField('Download');
foreach ($newPageSet as $i => $page) {
$page->HasBrokenLink = 0;
$page->HasBrokenFile = 0;
$content->setValue($page->Content);
$content->saveInto($page);
$download->setValue($page->Download);
$download->saveInto($page);
echo "<li>{$page->Title} (link:{$page->HasBrokenLink}, file:{$page->HasBrokenFile})";
$page->writeWithoutVersion();
$page->destroy();
$newPageSet[$i] = null;
}
}
示例4: HiddenField
function __construct($controller, $name, $article = null, bool $is_manager, $use_actions = true)
{
$IDField = new HiddenField('newsID');
//madatory fields
$HeadlineField = new TextField('headline', 'Headline (150 character max)', '', $maxLength = 150);
$HeadlineField->addExtraClass('headline');
$SummaryField = new HtmlEditorField('summary', 'Summary (300 character max)');
$SummaryField->addExtraClass('summary');
$SummaryField->setAttribute('max_chars', 300);
$CityField = new TextField('city', 'City');
$StateField = new TextField('state', 'State');
$CountryField = new CountryDropdownField('country', 'Country');
$TagsField = new TextField('tags', 'Tags');
$DateEmbargoField = new TextField('date_embargo', 'Desired release date/time: Time zone is Central Time. Please ensure your release date is in Central Time
(<a target="_blank" href="http://www.timeanddate.com/worldclock/converter.html">time converter</a>)');
$DateEmbargoField->addExtraClass('datefield');
if ($is_manager) {
$DateExpireField = new TextField('date_expire', 'Expire Date');
$DateExpireField->addExtraClass('datefield');
}
$UpdatedField = new DatetimeField_Readonly('date_updated', 'Last Updated');
//$UpdatedField->addExtraClass('inline');
//optional fields
$BodyField = new HtmlEditorField('body', 'Body');
$LinkField = new TextField('link', 'Link');
$DocumentField = new CustomUploadField('Document', 'Document');
$DocumentField->addExtraClass('hidden');
$DocumentField->setCanAttachExisting(false);
$DocumentField->setAllowedMaxFileNumber(1);
$DocumentField->setAllowedFileCategories('doc');
$DocumentField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
$DocumentField->setFolderName('news-documents');
$sizeMB = 1;
// 1 MB
$size = $sizeMB * 1024 * 1024;
// 1 MB in bytes
$DocumentField->getValidator()->setAllowedMaxFileSize($size);
$DocumentField->setCanPreviewFolder(false);
// Don't show target filesystem folder on upload field
$DocumentField->setRecordClass('File');
$ImageField = new CustomUploadField('Image', 'Image (Max size 2Mb - Suggested size 300x250px)');
$ImageField->setCanAttachExisting(false);
$ImageField->setAllowedMaxFileNumber(1);
$ImageField->setAllowedFileCategories('image');
$ImageField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
$ImageField->setFolderName('news-images');
$ImageField->setRecordClass('BetterImage');
$ImageField->getUpload()->setReplaceFile(false);
$ImageField->setOverwriteWarning(false);
$sizeMB = 2;
// 2 MB
$size = $sizeMB * 1024 * 1024;
// 2 MB in bytes
$ImageField->getValidator()->setAllowedMaxFileSize($size);
$ImageField->setCanPreviewFolder(false);
// Don't show target filesystem folder on upload field
if ($is_manager) {
$IsLandscapeField = new CheckboxField('is_landscape', 'Is Banner? (landscape image)');
$IsLandscapeField->addExtraClass('is_landscape');
}
if ($article) {
$IDField->setValue($article->ID);
$HeadlineField->setValue($article->Headline);
$SummaryField->setValue($article->Summary);
$CityField->setValue($article->City);
$StateField->setValue($article->State);
$CountryField->setValue($article->Country);
$TagsField->setValue($article->getTagsCSV());
if ($article->DateEmbargo) {
$DateEmbargoField->setValue(date('m/d/Y g:i a', strtotime($article->DateEmbargo)));
} else {
$DateEmbargoField->setValue(gmdate('m/d/Y g:i a'));
}
$UpdatedField->setValue($article->LastEdited);
$BodyField->setValue($article->Body);
$LinkField->setValue($article->Link);
if ($article->DateExpire) {
$DateExpireField->setValue(date('m/d/Y g:i a', strtotime($article->DateExpire)));
}
$IsLandscapeField->setValue($article->IsLandscape);
//submitter read only
$SubmitterFirstNameField = new ReadonlyField('submitter_first_name', 'First Name');
$SubmitterLastNameField = new ReadonlyField('submitter_last_name', 'Last Name');
$SubmitterEmailField = new ReadonlyField('submitter_email', 'Email');
$SubmitterCompanyField = new ReadonlyField('submitter_company', 'Company');
$SubmitterPhoneField = new ReadonlyField('submitter_phone', 'Phone');
$SubmitterFirstNameField->setValue($article->getSubmitter()->FirstName);
$SubmitterLastNameField->setValue($article->getSubmitter()->LastName);
$SubmitterEmailField->setValue($article->getSubmitter()->Email);
$SubmitterCompanyField->setValue($article->getSubmitter()->Company);
$SubmitterPhoneField->setValue($article->getSubmitter()->Phone);
} else {
// submitter fields
$SubmitterFirstNameField = new TextField('submitter_first_name', 'First Name');
$SubmitterLastNameField = new TextField('submitter_last_name', 'Last Name');
$SubmitterEmailField = new TextField('submitter_email', 'Email');
$SubmitterCompanyField = new TextField('submitter_company', 'Company');
$SubmitterPhoneField = new TextField('submitter_phone', 'Phone');
$LinkField->setValue('http://');
}
//.........这里部分代码省略.........
示例5: buildbrokenlinks
function buildbrokenlinks()
{
if ($this->urlParams['ID']) {
$newPageSet[] = DataObject::get_by_id("Page", $this->urlParams['ID']);
} else {
$pages = DataObject::get("Page");
foreach ($pages as $page) {
$newPageSet[] = $page;
}
$pages = null;
}
$content = new HtmlEditorField('Content');
$download = new HtmlEditorField('Download');
foreach ($newPageSet as $i => $page) {
$page->HasBrokenLink = 0;
$page->HasBrokenFile = 0;
$lastUsage = memory_get_usage() - $lastPoint;
$lastPoint = memory_get_usage();
$content->setValue($page->Content);
$content->saveInto($page);
$download->setValue($page->Download);
$download->saveInto($page);
echo "<li>{$page->Title} (link:{$page->HasBrokenLink}, file:{$page->HasBrokenFile})";
$page->writeWithoutVersion();
$page->destroy();
$newPageSet[$i] = null;
}
}
示例6: testBrokenFileLinkTracking
public function testBrokenFileLinkTracking()
{
$sitetree = new SiteTree();
$editor = new HtmlEditorField('Content');
$this->assertFalse((bool) $sitetree->HasBrokenFile);
$editor->setValue('<p><a href="[file_link,id=0]">Broken Link</a></p>');
$editor->saveInto($sitetree);
$sitetree->write();
$this->assertTrue($sitetree->HasBrokenFile);
$editor->setValue(sprintf('<p><a href="[file_link,id=%d]">Working Link</a></p>', $this->idFromFixture('File', 'example_file')));
$sitetree->HasBrokenFile = false;
$editor->saveInto($sitetree);
$sitetree->write();
$this->assertFalse((bool) $sitetree->HasBrokenFile);
}