private function parse($content) { $parser = new BBCodeParser(); $parser->set_content($content); $parser->parse(); return $parser->get_content(); }
/** * {@inheritdoc} */ public function get_parser() { $parser = new BBCodeParser(); $parser->set_forbidden_tags($this->get_forbidden_tags()); $parser->set_html_auth($this->get_html_auth()); return $parser; }
/** * @see BBCode::getParsedTag() */ public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { if (StringUtil::indexOf($content, '[*]') !== false) { // get list elements $listElements = preg_split('/\\[\\*\\]/', StringUtil::trim($content), -1, PREG_SPLIT_NO_EMPTY); // remove empty elements foreach ($listElements as $key => $val) { $listElements[$key] = StringUtil::trim($val); if (empty($listElements[$key]) || $listElements[$key] == '<br />') { unset($listElements[$key]); } } if (count($listElements) > 0) { // get list style type $listType = 'disc'; if (isset($openingTag['attributes'][0])) { $listType = $openingTag['attributes'][0]; } $listType = strtolower($listType); // replace old types if ($listType == '1') { $listType = 'decimal'; } if ($listType == 'a') { $listType = 'lower-latin'; } if ($parser->getOutputType() == 'text/html') { // build list html $listHTML = 'ol'; if ($listType == 'none' || $listType == 'circle' || $listType == 'square' || $listType == 'disc') { $listHTML = 'ul'; } return '<' . $listHTML . ' style="list-style-type: ' . $listType . '"><li>' . implode('</li><li>', $listElements) . '</li></' . $listHTML . '>'; } else { if ($parser->getOutputType() == 'text/plain') { $result = ''; $i = 1; foreach ($listElements as $listElement) { switch ($listType) { case 'decimal': $result .= $i . '. '; break; default: $result .= '- '; } $result .= $listElement . "\n"; $i++; } return $result; } } } } // no valid list // return bbcode as text return $openingTag['source'] . $content . $closingTag['source']; }
protected function btnButton_Click($strFormId, $strControlId, $strParameter) { $strText = $this->txtInput->Text; // Parse the text, this is the class that knows how to act // on our rules $objParser = new BBCodeParser($strText); $result = $objParser->Render(); $this->lblResultRaw->Text = $result; $this->lblResultFormatted->Text = $result; }
function Content() { if (self::$allow_wysiwyg_editing) { return $this->getField('Content'); } else { $parser = new BBCodeParser($this->Content); $content = new HTMLText('Content'); $content->value = $parser->parse(); return $content; } }
/** * @see BBCode::getParsedTag() */ public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { if ($parser->getOutputType() == 'text/html') { // show template WCF::getTPL()->assign(array('content' => $content, 'spoilerTitle' => !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')); return WCF::getTPL()->fetch('spoilerBBCodeTag'); } else { if ($parser->getOutputType() == 'text/plain') { return "[SPOILER]\n"; } } }
/** * @see BBCode::getParsedTag() */ public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { if ($parser->getOutputType() == 'text/html') { // encode html $content = self::trim($content); $content = StringUtil::encodeHTML($content); // show template WCF::getTPL()->assign(array('lineNumbers' => $this->makeLineNumbers($content, $this->getLineNumbersStart($openingTag)), 'content' => $content, 'codeBoxName' => WCF::getLanguage()->get('wcf.bbcode.code.title'))); return WCF::getTPL()->fetch('codeBBCodeTag'); } else { if ($parser->getOutputType() == 'text/plain') { return WCF::getLanguage()->get('wcf.bbcode.code.text', array('$content' => $content)); } } }
/** * @see BBCode::getParsedTag() */ public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { if ($parser->getOutputType() == 'text/html') { // show template WCF::getTPL()->assign(array('content' => $content, 'quoteLink' => !empty($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : '', 'quoteAuthor' => !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')); return WCF::getTPL()->fetch('quoteBBCodeTag'); } else { if ($parser->getOutputType() == 'text/plain') { $cite = ''; if (!empty($openingTag['attributes'][0])) { $cite = WCF::getLanguage()->get('wcf.bbcode.quote.cite.text', array('$name' => $openingTag['attributes'][0])); } return WCF::getLanguage()->get('wcf.bbcode.quote.text', array('$content' => $content, '$cite' => $cite)); } } }
/** * @see BBCode::getParsedTag() */ public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { if (WCF::getUser()->getPermission('user.message.canUseBBCodeThreadClosed')) { if ($parser->getOutputType() == 'text/html') { // show template WCF::getTPL()->assign(array('content' => $content)); return WCF::getTPL()->fetch('threadclosedBBCodeTag'); } else { if ($parser->getOutputType() == 'text/plain') { return $content; } } } else { return false; } }
/** * Main BBCode parser method. This takes plain jane content and * runs it through so many filters * * @return DBField */ public function parse() { // Convert content to plain text $this->content = DBField::create_field('HTMLFragment', $this->content)->Plain(); $p = new SSHTMLBBCodeParser(); $this->content = $p->qparse($this->content); unset($p); if ($this->config()->allow_smilies) { $smilies = array('#(?<!\\w):D(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/grin.gif'> ", '#(?<!\\w):\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/smile.gif'> ", '#(?<!\\w):-\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/smile.gif'> ", '#(?<!\\w):\\((?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/sad.gif'> ", '#(?<!\\w):-\\((?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/sad.gif'> ", '#(?<!\\w):p(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/tongue.gif'> ", '#(?<!\\w)8-\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/cool.gif'> ", '#(?<!\\w):\\^\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/confused.gif'> "); $this->content = preg_replace(array_keys($smilies), array_values($smilies), $this->content); } // Ensure to return cast value return DBField::create_field('HTMLFragment', $this->content); }
/** * @see BBCode::getParsedTag() */ public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { $url = ''; if (isset($openingTag['attributes'][0])) { $url = $openingTag['attributes'][0]; } $noTitle = $content == $url; // add protocol if necessary if (!preg_match("/[a-z]:\\/\\//si", $url)) { $url = 'http://' . $url; } if ($parser->getOutputType() == 'text/html') { $external = true; if (($newURL = $this->isInternalURL($url)) !== false) { $url = $newURL; $external = false; } // cut visible url if ($noTitle) { $decodedContent = StringUtil::decodeHTML($content); if (StringUtil::length($decodedContent) > 60) { $content = StringUtil::encodeHTML(StringUtil::substring($decodedContent, 0, 40)) . '…' . StringUtil::encodeHTML(StringUtil::substring($decodedContent, -15)); } } else { $content = StringUtil::trim($content); } return '<a href="' . $url . '"' . ($external ? ' class="externalURL"' : '') . '>' . $content . '</a>'; } else { if ($parser->getOutputType() == 'text/plain') { if ($noTitle) { return $url; } return $content . ': ' . $url; } } }
/** * Main BBCode parser method. This takes plain jane content and * runs it through so many filters * * @return Text */ function parse() { $this->content = str_replace(array('&', '<', '>'), array('&', '<', '>'), $this->content); $this->content = SSHTMLBBCodeParser::staticQparse($this->content); $this->content = "<p>" . $this->content . "</p>"; $this->content = preg_replace('/(<p[^>]*>)\\s+/i', '\\1', $this->content); $this->content = preg_replace('/\\s+(<\\/p[^>]*>)/i', '\\1', $this->content); $this->content = preg_replace("/\n\\s*\n/", "</p><p>", $this->content); $this->content = str_replace("\n", "<br />", $this->content); if (BBCodeParser::smiliesAllowed()) { $smilies = array('#(?<!\\w):D(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/grin.gif'> ", '#(?<!\\w):\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/smile.gif'> ", '#(?<!\\w):-\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/smile.gif'> ", '#(?<!\\w):\\((?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/sad.gif'> ", '#(?<!\\w):-\\((?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/sad.gif'> ", '#(?<!\\w):p(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/tongue.gif'> ", '#(?<!\\w)8-\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/cool.gif'> ", '#(?<!\\w):\\^\\)(?!\\w)#i' => " <img src='" . BBCodeParser::smilies_location() . "/confused.gif'> "); $this->content = preg_replace(array_keys($smilies), array_values($smilies), $this->content); } return $this->content; }
/** * @see BBCode::getParsedTag() */ public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) { if (self::$messageID == 0 && !isset(self::$attachments[self::$messageID]) && count(self::$attachments) == 1) { // get first message id $keys = array_keys(self::$attachments); self::$messageID = reset($keys); } if (isset($openingTag['attributes'][0])) { $attachmentID = $openingTag['attributes'][0]; if (isset(self::$attachments[self::$messageID]['images'][$attachmentID])) { // image $attachment = self::$attachments[self::$messageID]['images'][$attachmentID]; if ($parser->getOutputType() == 'text/html') { $align = isset($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : ''; $result = '<img src="index.php?page=Attachment&attachmentID=' . $attachmentID . ($attachment->thumbnailType ? '&thumbnail=1' : '') . '&embedded=1" alt="" class="embeddedAttachment" style="width: ' . ($attachment->thumbnailType ? $attachment->getThumbnailWidth() : $attachment->getWidth()) . 'px; height: ' . ($attachment->thumbnailType ? $attachment->getThumbnailHeight() : $attachment->getHeight()) . 'px;' . (!empty($align) ? ' float:' . StringUtil::encodeHTML($align) . '; margin: ' . ($align == 'left' ? '0 15px 7px 0' : '0 0 7px 15px') : '') . '" />'; if ($attachment->thumbnailType) { $result = '<a href="index.php?page=Attachment&attachmentID=' . $attachmentID . '" class="enlargable">' . $result . '</a>'; } return $result; } else { if ($parser->getOutputType() == 'text/plain') { return ($content != $attachmentID ? $content : $attachment->attachmentName) . ': ' . PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID . ($attachment->thumbnailType ? '&thumbnail=1' : ''); } } } else { if (isset(self::$attachments[self::$messageID]['files'][$attachmentID])) { // file $attachment = self::$attachments[self::$messageID]['files'][$attachmentID]; if ($parser->getOutputType() == 'text/html') { return '<a href="index.php?page=Attachment&attachmentID=' . $attachmentID . '">' . (!empty($content) && $content != $attachmentID ? $content : StringUtil::encodeHTML($attachment->attachmentName)) . '</a>'; } else { if ($parser->getOutputType() == 'text/plain') { return ($content != $attachmentID ? $content : $attachment->attachmentName) . ': ' . PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID; } } } } } if ($parser->getOutputType() == 'text/html') { return '<a href="index.php?page=Attachment&attachmentID=' . $attachmentID . '">index.php?page=Attachment&attachmentID=' . $attachmentID . '</a>'; } else { if ($parser->getOutputType() == 'text/plain') { return PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID; } } }
<?php DataObject::add_extension('Member', 'ForumRole'); Object::add_extension('Member_Validator', 'ForumRole_Validator'); BBCodeParser::enable_smilies();
<?php // //Object::add_extension('Member', 'MicroBlogMember'); //Object::add_extension('Member', 'Restrictable'); //Object::add_extension('Group', 'Restrictable'); // //Object::add_extension('DashboardPage', 'MicroblogDashboard'); // //Object::add_extension('SiteConfig', 'Restrictable'); // //Object::add_extension('Image', 'MaximumSizeImageExtension'); // //DashboardController::set_allowed_dashlets(array( // 'TimelineDashlet', // 'ProfileDashlet', // 'FriendsDashlet', // 'TagsDashlet' //)); BBCodeParser::enable_smilies(true);
/** * Обработка BB-кодов * @param string $text Необработанный текст * @param boolean $parse Обрабатывать или вырезать код * @return string Обработанный текст */ public static function bbCode($text, $parse = true) { $bbcode = new BBCodeParser(); if (!$parse) { return $bbcode->clear($text); } $text = $bbcode->parse($text); $text = $bbcode->parseSmiles($text); return $text; }
/** * Get the usable BB codes * * @return DataObjectSet Returns the usable BB codes * @see BBCodeParser::usable_tags() */ function BBTags() { return BBCodeParser::usable_tags(); }
/*---------- Design Patterns: Decorator Pattern ----------*/ print "<br/><br/>"; $bbcode_enabled = 0; $emoticon_enabled = 1; $post = new Post(); $comment = new Comment(); $post->filter("Test Title: A Test", "Lorem Ipsum Amet"); $comment->filter("Dolot avenus persina olatus"); if ($bbcode_enabled == false && $emoticon_enabled == false) { $postcontent = $post->getContent(); $commentcontent = $comment->getContent(); } elseif ($bbcode_enabled == true && $emoticon_enabled == false) { $bb = new BBCodeParser($post); // Passing the Post() object to BBCodeParser() $postcontent = $bb->getContent(); $bb = new BBCodeParser($comment); $commentcontent = $bb->getContent(); } elseif ($bbcode_enabled == false && $emoticon_enabled == true) { $em = new EmoticonParser($post); $postcontent = $em->getContent(); $em = new EmoticonParser($comment); $commentcontent = $em->getContent(); } /*---------- Design Patterns: Facade Pattern ----------*/ $F = new Facade(); $F->findApartments("London, Greater London", "mapdiv"); /** Sumary: - Design Pattern are an essential part of OOP */
/** * Intelligently expand a URL into a link * * @return string * @access private * @author Seth Price <*****@*****.**> * @author Lorenzo Alberton <*****@*****.**> */ public function smarterPPLinkExpand($matches) { $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser', '_options'); $o = $options['open']; $c = $options['close']; //If we have an intro tag that is [url], then skip this match if ($matches[1] == $o . 'url' . $c) { return $matches[0]; } if (!BBCodeParser::autolinkUrls()) { return $matches[0]; } $punctuation = '.,;:'; // Links can't end with these chars $trailing = ''; // Knock off ending punctuation $last = substr($matches[2], -1); while (strpos($punctuation, $last) !== false) { // Last character is punctuation - remove it from the url $trailing = $last . $trailing; $matches[2] = substr($matches[2], 0, -1); $last = substr($matches[2], -1); } $off = strpos($matches[2], ':'); //Is a ":" (therefore a scheme) defined? if ($off === false) { /* * Create a link with the default scheme of http. Notice that the * text that is viewable to the user is unchanged, but the link * itself contains the "http://". */ return $matches[1] . $o . 'url=' . $this->_defaultScheme . '://' . $matches[2] . $c . $matches[2] . $o . '/url' . $c . $trailing; } $scheme = substr($matches[2], 0, $off); /* * If protocol is in the approved list than allow it. Note that this * check isn't really needed, but the created link will just be deleted * later in smarterPPLink() if we create it now and it isn't on the * scheme list. */ if (in_array($scheme, $this->_allowedSchemes)) { return $matches[1] . $o . 'url' . $c . $matches[2] . $o . '/url' . $c . $trailing; } return $matches[0]; }
public function action_postedit($topic_slug, $topic_id, $message_id) { $topic = Forumtopic::find($topic_id); if (is_null($topic)) { return Event::first('404'); } $category = $topic->category; $message = Forummessage::find($message_id); if (is_null($message)) { return Event::first('404'); } if ($message->user->id != Auth::user()->id && !Auth::user()->is('Forumer')) { return Event::first('404'); } $rules = array('content' => 'required|min:30'); $content = trim(Input::get('content')); $toValidate = compact('content'); $editTitle = false; if ($topic->messages[0]->id == $message->id && trim(Input::get('title')) != $topic->title) { $editTitle = true; $rules['title'] = 'required|min:2'; $title = trim(Input::get('title')); $toValidate['title'] = $title; } $validator = Validator::make($toValidate, $rules); if ($validator->fails()) { return Redirect::back()->with_errors($validator)->with_input(); } if ($editTitle) { $topic->title = $toValidate['title']; $topic->slug = Str::slug($toValidate['title']); $originalSlug = $topic->slug; $incSlug = 0; do { try { $topic->save(); $incSlug = 0; } catch (Exception $e) { if ($e->getCode() == 23000) { $incSlug++; } $topic->slug = $originalSlug . '-' . $incSlug; } } while ($incSlug != 0); } $message->content = BBCodeParser::parse($content); $message->content_bbcode = $content; $message->save(); $topic->touch(); $topic_id = $topic->id; $topic_slug = $topic->slug; $url = URL::to_action('forums::topic@index', compact('topic_slug', 'topic_id')) . '?page=last#message' . $message->id; return Redirect::to($url); }
/** * @see BBCodeParser::isValidTagAttribute() */ protected function isValidTagAttribute($tagAttributes, $definedTagAttribute) { if (!parent::isValidTagAttribute($tagAttributes, $definedTagAttribute)) { return false; } // check for cached codes if (isset($tagAttributes[$definedTagAttribute['attributeNo']]) && preg_match('/@@[a-f0-9]{40}@@/', $tagAttributes[$definedTagAttribute['attributeNo']])) { return false; } return true; }
<?php include 'BBCodeParser.class.php'; $bbcode = new BBCodeParser(); $default_content = '[p][size=18][b]Lorem ipsum[/b][/size] dolor sit amet, [i]consectetur adipiscing[/i] [u]elit[/u]. Maecenas rhoncus, [color=red]quam id[/color] aliquet volutpat, sapien mauris posuere orci, ut accumsan augue enim quis [s]libero.[/p] [quote=Marcus]Fusce nec ex neque. Nunc mattis ut turpis id consectetur. [font=Time]Ut vehicula blandit[/font] justo quis posuere. Etiam scelerisque turpis at massa facilisis, ac molestie tortor ornare.[/quote] [list] Vestibulum ultrices elit nec libero mattis, ac placerat leo laoreet. Proin sed ex mollis risus pulvinar interdum nec eu leo. Duis iaculis ligula eu ante porta hendrerit. [/list] [list=A] [*] Nunc mattis ut turpis id consectetur. Etiam scelerisque turpis at massa facilisis. [*] Fusce nec ex neque. [/list] [code] #include <iostream> int main() { using std::cout; cout << "Hello, new world !" << std::endl; } [/code] [url=http://www.w3.org]Nam ullamcorper[/url]
static function disable_autolink_urls($autolink = false) { BBCodeParser::$autolinkUrls = $autolink; }
/** * Return the parsed content and the information for the * RSS feed */ function getRSSContent() { $parser = new BBCodeParser($this->Content); $html = $parser->parse(); if ($this->Thread()) { $html .= '<br><br>' . sprintf(_t('Post.POSTEDTO', "Posted to: %s"), $this->Thread()->Title); } $html .= " " . $this->ShowLink() . " | " . $this->ReplyLink(); return $html; }
function ParsedBBCode() { $parser = new BBCodeParser($this->Comment); return $parser->parse(); }
/** * A simple form for creating blog entries */ function BlogEntryForm() { if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure(); Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript('jsparty/prototype.js'); Requirements::javascript('jsparty/scriptaculous/effects.js'); Requirements::javascript('cms/javascript/PageCommentInterface.js'); Requirements::javascript('blog/javascript/bbcodehelp.js'); $id = 0; if(Director::urlParam('ID')) { $id = (int) Director::urlParam('ID'); } $codeparser = new BBCodeParser(); $membername = Member::currentMember() ? Member::currentMember()->getName() : ""; if(BlogEntry::$allow_wysiwyg_editing) { $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN")); } else { $contentfield = new CompositeField( new LiteralField("BBCodeHelper","<a id=\"BBCodeHint\" target='new'>"._t("BlogEntry.BBH")."</a><div class='clear'><!-- --></div>" ), new TextareaField("BlogPost", _t("BlogEntry.CN"),20), // This is called BlogPost as the id #Content is generally used already new LiteralField("BBCodeTags","<div id=\"BBTagsHolder\">".$codeparser->useable_tagsHTML()."</div>") ); } if(class_exists('TagField')) { $tagfield = new TagField('Tags', null, null, 'BlogEntry'); $tagfield->setSeparator(', '); } else { $tagfield = new TextField('Tags'); } $fields = new FieldSet( new HiddenField("ID", "ID"), new TextField("Title",_t('BlogHolder.SJ', "Subject")), new TextField("Author",_t('BlogEntry.AU'),$membername), $contentfield, $tagfield, new LiteralField("Tagsnote"," <label id='tagsnote'>"._t('BlogHolder.TE', "For example: sport, personal, science fiction")."<br/>" . _t('BlogHolder.SPUC', "Please separate tags using commas.")."</label>") ); $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry')); $actions = new FieldSet($submitAction); $validator = new RequiredFields('Title','Content'); $form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator); if($id != 0) { $entry = DataObject::get_by_id('BlogEntry', $id); $form->loadNonBlankDataFrom($entry); $form->datafieldByName('BlogPost')->setValue($entry->Content); } else { $form->loadNonBlankDataFrom(array("Author" => Cookie::get("BlogHolder_Name"))); } return $form; }
/** * A simple form for creating blog entries */ function BlogEntryForm() { if (!Permission::check('BLOGMANAGEMENT')) { return Security::permissionFailure(); } $id = 0; if ($this->request->latestParam('ID')) { $id = (int) $this->request->latestParam('ID'); } $codeparser = new BBCodeParser(); $membername = Member::currentMember() ? Member::currentMember()->getName() : ""; if (BlogEntry::$allow_wysiwyg_editing) { $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN")); } else { $contentfield = new CompositeField(new LiteralField("BBCodeHelper", "<a id=\"BBCodeHint\" target='new'>" . _t("BlogEntry.BBH") . "</a><div class='clear'><!-- --></div>"), new TextareaField("BlogPost", _t("BlogEntry.CN"), 20), new LiteralField("BBCodeTags", "<div id=\"BBTagsHolder\">" . $codeparser->useable_tagsHTML() . "</div>")); } if (class_exists('TagField')) { $tagfield = new TagField('Tags', null, null, 'BlogEntry'); $tagfield->setSeparator(', '); } else { $tagfield = new TextField('Tags'); } $field = 'TextField'; if (!$this->AllowCustomAuthors && !Permission::check('ADMIN')) { $field = 'ReadonlyField'; } $fields = new FieldSet(new HiddenField("ID", "ID"), new TextField("Title", _t('BlogHolder.SJ', "Subject")), new $field("Author", _t('BlogEntry.AU'), $membername), $contentfield, $tagfield, new LiteralField("Tagsnote", " <label id='tagsnote'>" . _t('BlogHolder.TE', "For example: sport, personal, science fiction") . "<br/>" . _t('BlogHolder.SPUC', "Please separate tags using commas.") . "</label>")); $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry')); $actions = new FieldSet($submitAction); $validator = new RequiredFields('Title', 'BlogPost'); $form = new Form($this, 'BlogEntryForm', $fields, $actions, $validator); if ($id != 0) { $entry = DataObject::get_by_id('BlogEntry', $id); if ($entry->IsOwner()) { $form->loadDataFrom($entry); $form->datafieldByName('BlogPost')->setValue($entry->Content); } } else { $form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name"))); } return $form; }