-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dfb8ac
commit 37408e4
Showing
9 changed files
with
1,713 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Created by Nivanka Fonseka ([email protected]). | ||
* User: nivankafonseka | ||
* Date: 4/18/15 | ||
* Time: 11:21 AM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
|
||
$strMarkDownPath = dirname(__FILE__); | ||
require_once($strMarkDownPath . '/thirdparty/parsedown/Parsedown.php'); | ||
|
||
if(!defined('MARKDOWN_BASE')){ | ||
$strBase = substr(str_replace(BASE_PATH, '', $strMarkDownPath), 1); | ||
define('MARKDOWN_BASE', $strBase); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Created by Nivanka Fonseka ([email protected]). | ||
* User: nivankafonseka | ||
* Date: 4/18/15 | ||
* Time: 11:12 AM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
|
||
class MarkdownEditorField extends TextareaField { | ||
|
||
protected $rows = 30; | ||
|
||
function Field($properties = array()){ | ||
Requirements::css(MARKDOWN_BASE . '/css/MarkdownEditorField.css'); | ||
return parent::Field($properties); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
/** | ||
* Created by Nivanka Fonseka ([email protected]). | ||
* User: nivankafonseka | ||
* Date: 4/18/15 | ||
* Time: 11:11 AM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
|
||
class MarkdownField extends Text { | ||
|
||
private static $escape_type = 'xml'; | ||
|
||
private static $casting = array( | ||
"AbsoluteLinks" => "HTMLText", | ||
"BigSummary" => "HTMLText", | ||
"ContextSummary" => "HTMLText", | ||
"FirstParagraph" => "HTMLText", | ||
"FirstSentence" => "HTMLText", | ||
"LimitCharacters" => "HTMLText", | ||
"LimitSentences" => "HTMLText", | ||
"Lower" => "HTMLText", | ||
"LowerCase" => "HTMLText", | ||
"Summary" => "HTMLText", | ||
"Upper" => "HTMLText", | ||
"UpperCase" => "HTMLText", | ||
'EscapeXML' => 'HTMLText', | ||
'LimitWordCount' => 'HTMLText', | ||
'LimitWordCountXML' => 'HTMLText', | ||
'NoHTML' => 'Text', | ||
); | ||
|
||
private $parsedContent; | ||
|
||
|
||
/** | ||
* @return string | ||
* parse contents of the markdown field to tempates | ||
*/ | ||
function ParseMarkdown($bCache = true, $strValue = ''){ | ||
if($bCache && $this->parsedContent) | ||
return $this->parsedContent; | ||
|
||
$shortCodeParser = ShortcodeParser::get_active(); | ||
$strParsed = $shortCodeParser->parse(!empty($strValue) ? $strValue : $this->value); | ||
|
||
$parseDown = new Parsedown(); | ||
$strParsed = $parseDown->text($strParsed); | ||
|
||
if($bCache) | ||
$this->parsedContent = $strParsed; | ||
|
||
return $strParsed; | ||
} | ||
|
||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function forTemplate() { | ||
return $this->ParseMarkdown(); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function __toString() { | ||
return (string)$this->value; | ||
} | ||
|
||
/** | ||
* @param null $title | ||
* @param null $params | ||
* @return FormField|MarkdownEditorField|NullableField|TextareaField | ||
*/ | ||
public function scaffoldFormField($title = null, $params = null) { | ||
return new MarkdownEditorField($this->name, $title); | ||
} | ||
|
||
|
||
/** | ||
* @param null $title | ||
* @param null $params | ||
* @return FormField|TextField | ||
*/ | ||
public function scaffoldSearchField($title = null, $params = null) { | ||
return new TextField($this->name, $title); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function NoHTML(){ | ||
return strip_tags($this->ParseMarkdown()); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function Upper(){ | ||
$strValue = strtoupper($this->__toString()); | ||
return $this->ParseMarkdown(false, $strValue); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function UpperCase(){ | ||
return $this->Upper(); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function Lower(){ | ||
$strValue = strtolower($this->__toString()); | ||
return $this->ParseMarkdown(false, $strValue); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function LowerCase(){ | ||
return $this->Lower(); | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.markdowneditor { | ||
|
||
|
||
.middleColumn { | ||
|
||
margin-left: 0; | ||
clear: both; | ||
|
||
textarea { | ||
width: 100%; | ||
max-width: 100%; | ||
} | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<textarea $AttributesHTML>$Value</textarea> |
Empty file.
Oops, something went wrong.