first commit
This commit is contained in:
10
application/third_party/Michelf/Markdown.inc.php
vendored
Executable file
10
application/third_party/Michelf/Markdown.inc.php
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
# Use this file if you cannot use class autoloading. It will include all the
|
||||
# files needed for the Markdown parser.
|
||||
#
|
||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
||||
# in the Readme.php file if you want a simple autoloader setup.
|
||||
|
||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||
require_once dirname(__FILE__) . '/Markdown.php';
|
||||
3144
application/third_party/Michelf/Markdown.php
vendored
Executable file
3144
application/third_party/Michelf/Markdown.php
vendored
Executable file
File diff suppressed because it is too large
Load Diff
11
application/third_party/Michelf/MarkdownExtra.inc.php
vendored
Executable file
11
application/third_party/Michelf/MarkdownExtra.inc.php
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
# Use this file if you cannot use class autoloading. It will include all the
|
||||
# files needed for the MarkdownExtra parser.
|
||||
#
|
||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
||||
# in the Readme.php file if you want a simple autoloader setup.
|
||||
|
||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||
require_once dirname(__FILE__) . '/Markdown.php';
|
||||
require_once dirname(__FILE__) . '/MarkdownExtra.php';
|
||||
37
application/third_party/Michelf/MarkdownExtra.php
vendored
Executable file
37
application/third_party/Michelf/MarkdownExtra.php
vendored
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
#
|
||||
# Markdown Extra - A text-to-HTML conversion tool for web writers
|
||||
#
|
||||
# PHP Markdown Extra
|
||||
# Copyright (c) 2004-2014 Michel Fortin
|
||||
# <http://michelf.com/projects/php-markdown/>
|
||||
#
|
||||
# Original Markdown
|
||||
# Copyright (c) 2004-2006 John Gruber
|
||||
# <http://daringfireball.net/projects/markdown/>
|
||||
#
|
||||
|
||||
|
||||
# Just force Michelf/Markdown.php to load. This is needed to load
|
||||
# the temporary implementation class. See below for details.
|
||||
\Michelf\Markdown::MARKDOWNLIB_VERSION;
|
||||
|
||||
#
|
||||
# Markdown Extra Parser Class
|
||||
#
|
||||
# Note: Currently the implementation resides in the temporary class
|
||||
# \Michelf\MarkdownExtra_TmpImpl (in the same file as \Michelf\Markdown).
|
||||
# This makes it easier to propagate the changes between the three different
|
||||
# packaging styles of PHP Markdown. Once this issue is resolved, the
|
||||
# _MarkdownExtra_TmpImpl will disappear and this one will contain the code.
|
||||
#
|
||||
|
||||
class MarkdownExtra extends \Michelf\_MarkdownExtra_TmpImpl {
|
||||
|
||||
### Parser Implementation ###
|
||||
|
||||
# Temporarily, the implemenation is in the _MarkdownExtra_TmpImpl class.
|
||||
# See note above.
|
||||
|
||||
}
|
||||
|
||||
9
application/third_party/Michelf/MarkdownInterface.inc.php
vendored
Executable file
9
application/third_party/Michelf/MarkdownInterface.inc.php
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
# Use this file if you cannot use class autoloading. It will include all the
|
||||
# files needed for the MarkdownInterface interface.
|
||||
#
|
||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
||||
# in the Readme.php file if you want a simple autoloader setup.
|
||||
|
||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||
34
application/third_party/Michelf/MarkdownInterface.php
vendored
Executable file
34
application/third_party/Michelf/MarkdownInterface.php
vendored
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
#
|
||||
# Markdown - A text-to-HTML conversion tool for web writers
|
||||
#
|
||||
# PHP Markdown
|
||||
# Copyright (c) 2004-2014 Michel Fortin
|
||||
# <http://michelf.com/projects/php-markdown/>
|
||||
#
|
||||
# Original Markdown
|
||||
# Copyright (c) 2004-2006 John Gruber
|
||||
# <http://daringfireball.net/projects/markdown/>
|
||||
#
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Markdown Parser Interface
|
||||
#
|
||||
|
||||
interface MarkdownInterface {
|
||||
|
||||
#
|
||||
# Initialize the parser and return the result of its transform method.
|
||||
# This will work fine for derived classes too.
|
||||
#
|
||||
public static function defaultTransform($text);
|
||||
|
||||
#
|
||||
# Main function. Performs some preprocessing on the input text
|
||||
# and pass it through the document gamut.
|
||||
#
|
||||
public function transform($text);
|
||||
|
||||
}
|
||||
10
application/third_party/Michelf/index.html
vendored
Executable file
10
application/third_party/Michelf/index.html
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
67
application/third_party/Sioen/Converter.php
vendored
Executable file
67
application/third_party/Sioen/Converter.php
vendored
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Class Converter
|
||||
*
|
||||
* A Sir Trevor to HTML conversion helper for PHP
|
||||
*
|
||||
* @version 1.1.0
|
||||
* @author Wouter Sioen <wouter@woutersioen.be>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
*/
|
||||
class Converter
|
||||
{
|
||||
/**
|
||||
* Converts the outputted json from Sir Trevor to html
|
||||
*
|
||||
* @param string $json
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml($json)
|
||||
{
|
||||
// convert the json to an associative array
|
||||
$input = json_decode($json, true);
|
||||
$html = '';
|
||||
|
||||
// loop trough the data blocks
|
||||
foreach ($input['data'] as $block) {
|
||||
$toHtmlContext = new ToHtmlContext($block['type']);
|
||||
$html .= $toHtmlContext->getHtml($block['data']);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts html to the json Sir Trevor requires
|
||||
*
|
||||
* @param string $html
|
||||
* @return string The json string
|
||||
*/
|
||||
public function toJson($html)
|
||||
{
|
||||
// Strip white space between tags to prevent creation of empty #text nodes
|
||||
$html = preg_replace('~>\s+<~', '><', $html);
|
||||
$document = new \DOMDocument();
|
||||
|
||||
// Load UTF-8 HTML hack (from http://bit.ly/pVDyCt)
|
||||
$document->loadHTML('<?xml encoding="UTF-8">' . $html);
|
||||
$document->encoding = 'UTF-8';
|
||||
|
||||
// fetch the body of the document. All html is stored in there
|
||||
$body = $document->getElementsByTagName("body")->item(0);
|
||||
|
||||
$data = array();
|
||||
|
||||
// loop trough the child nodes and convert them
|
||||
if ($body) {
|
||||
foreach ($body->childNodes as $node) {
|
||||
$toJsonContext = new ToJsonContext($node->nodeName);
|
||||
$data[] = $toJsonContext->getData($node);
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode(array('data' => $data));
|
||||
}
|
||||
}
|
||||
108
application/third_party/Sioen/Tests/ConverterTest.php
vendored
Executable file
108
application/third_party/Sioen/Tests/ConverterTest.php
vendored
Executable file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Sioen\Tests;
|
||||
|
||||
use Sioen\Converter;
|
||||
|
||||
class ConverterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testToHtml()
|
||||
{
|
||||
$converter = new Converter();
|
||||
|
||||
// let's try a basic json
|
||||
$json = json_encode(array(
|
||||
'data' => array(array(
|
||||
'type' => 'quote',
|
||||
'data' => array(
|
||||
'text' => 'Text',
|
||||
'cite' => 'Cite'
|
||||
)
|
||||
))
|
||||
));
|
||||
$html = $converter->toHtml($json);
|
||||
$this->assertEquals(
|
||||
$html,
|
||||
"<blockquote><p>Text</p>\n<cite><p>Cite</p>\n</cite></blockquote>"
|
||||
);
|
||||
|
||||
// Lets convert a normal text type that uses the default converter
|
||||
$json = json_encode(array(
|
||||
'data' => array(array(
|
||||
'type' => 'text',
|
||||
'data' => array(
|
||||
'text' => 'test'
|
||||
)
|
||||
))
|
||||
));
|
||||
$html = $converter->toHtml($json);
|
||||
$this->assertEquals($html, "<p>test</p>\n");
|
||||
|
||||
// the video conversion
|
||||
$json = json_encode(array(
|
||||
'data' => array(array(
|
||||
'type' => 'video',
|
||||
'data' => array(
|
||||
'source' => 'youtube',
|
||||
'remote_id' => '4BXpi7056RM'
|
||||
)
|
||||
))
|
||||
));
|
||||
$html = $converter->toHtml($json);
|
||||
$this->assertEquals(
|
||||
$html,
|
||||
"<iframe src=\"//www.youtube.com/embed/4BXpi7056RM?rel=0\" frameborder=\"0\" allowfullscreen></iframe>\n"
|
||||
);
|
||||
|
||||
// The heading
|
||||
$json = json_encode(array(
|
||||
'data' => array(array(
|
||||
'type' => 'heading',
|
||||
'data' => array(
|
||||
'text' => 'test'
|
||||
)
|
||||
))
|
||||
));
|
||||
$html = $converter->toHtml($json);
|
||||
$this->assertEquals($html, "<h2>test</h2>\n");
|
||||
|
||||
// images
|
||||
$json = json_encode(array(
|
||||
'data' => array(array(
|
||||
'type' => 'image',
|
||||
'data' => array(
|
||||
'file' => array(
|
||||
'url' => '/frontend/files/sir-trevor/images/IMG_3867.JPG'
|
||||
)
|
||||
)
|
||||
))
|
||||
));
|
||||
$html = $converter->toHtml($json);
|
||||
$this->assertEquals($html, "<img src=\"/frontend/files/sir-trevor/images/IMG_3867.JPG\" />\n");
|
||||
}
|
||||
|
||||
public function testToJson()
|
||||
{
|
||||
$converter = new Converter();
|
||||
$this->assertEquals(
|
||||
$converter->toJson('<h2>Test</h2>'),
|
||||
'{"data":[{"type":"heading","data":{"text":" Test"}}]}'
|
||||
);
|
||||
|
||||
// a quote
|
||||
$this->assertEquals(
|
||||
$converter->toJson('<blockquote><p>Text</p><cite>Cite</cite></blockquote>'),
|
||||
'{"data":[{"type":"quote","data":{"text":" Text","cite":" Cite"}}]}'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$converter->toJson('<blockquote><p>Text</p></blockquote>'),
|
||||
'{"data":[{"type":"quote","data":{"text":" Text","cite":""}}]}'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$converter->toJson('<img src="/path/to/img.jpg" />'),
|
||||
'{"data":[{"type":"image","data":{"file":{"url":"\/path\/to\/img.jpg"}}}]}'
|
||||
);
|
||||
}
|
||||
}
|
||||
10
application/third_party/Sioen/Tests/index.html
vendored
Executable file
10
application/third_party/Sioen/Tests/index.html
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
49
application/third_party/Sioen/ToHtmlContext.php
vendored
Executable file
49
application/third_party/Sioen/ToHtmlContext.php
vendored
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
class ToHtmlContext {
|
||||
|
||||
protected $converter = null;
|
||||
|
||||
public function __construct($type) {
|
||||
switch ($type) {
|
||||
case 'heading':
|
||||
$this->converter = new HeadingConverter();
|
||||
break;
|
||||
case 'columns':
|
||||
$this->converter = new ColumnsConverter();
|
||||
break;
|
||||
case 'button':
|
||||
$this->converter = new ButtonConverter();
|
||||
break;
|
||||
case 'accordion':
|
||||
$this->converter = new AccordionConverter();
|
||||
break;
|
||||
case 'list':
|
||||
$this->converter = new ListConverter();
|
||||
break;
|
||||
case 'quote':
|
||||
$this->converter = new BlockquoteConverter();
|
||||
break;
|
||||
case 'video':
|
||||
$this->converter = new IframeConverter();
|
||||
break;
|
||||
case 'iframe':
|
||||
$this->converter = new IframeExtendedConverter();
|
||||
break;
|
||||
case 'image':
|
||||
$this->converter = new ImageConverter();
|
||||
break;
|
||||
case 'image_extended':
|
||||
$this->converter = new ImageExtendedConverter();
|
||||
break;
|
||||
default:
|
||||
$this->converter = new BaseConverter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getHtml(array $data) {
|
||||
return $this->converter->toHtml($data);
|
||||
}
|
||||
|
||||
}
|
||||
40
application/third_party/Sioen/ToJsonContext.php
vendored
Executable file
40
application/third_party/Sioen/ToJsonContext.php
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
class ToJsonContext
|
||||
{
|
||||
protected $converter = null;
|
||||
|
||||
public function __construct($nodeName)
|
||||
{
|
||||
switch ($nodeName) {
|
||||
case 'p':
|
||||
$this->converter = new ParagraphConverter();
|
||||
break;
|
||||
case 'h2':
|
||||
$this->converter = new HeadingConverter();
|
||||
break;
|
||||
case 'ul':
|
||||
$this->converter = new ListConverter();
|
||||
break;
|
||||
case 'blockquote':
|
||||
$this->converter = new BlockquoteConverter();
|
||||
break;
|
||||
case 'iframe':
|
||||
$this->converter = new IframeConverter();
|
||||
break;
|
||||
case 'img':
|
||||
$this->converter = new ImageConverter();
|
||||
break;
|
||||
default:
|
||||
$this->converter = new BaseConverter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getData(\DOMElement $node)
|
||||
{
|
||||
return $this->converter->toJson($node);
|
||||
}
|
||||
}
|
||||
36
application/third_party/Sioen/Types/AccordionConverter.php
vendored
Executable file
36
application/third_party/Sioen/Types/AccordionConverter.php
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
|
||||
class AccordionConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
return array(
|
||||
'type' => 'image',
|
||||
'data' => array(
|
||||
'file' => array(
|
||||
'url' => $node->getAttribute('src')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
|
||||
$html = "<div id='accordion' class='panel-group'>";
|
||||
$i = 0;
|
||||
foreach ($data['panels'] as $panel) {
|
||||
$html .= "<div class='panel panel-default'><div class='panel-heading'>";
|
||||
$html .= "<h4 class='panel-title'><a data-toggle='collapse' data-parent='#accordion' href='#collapse".$i."'>".$panel['title']."</a></h4></div>";
|
||||
$html .= "<div id='collapse".$i."' class='panel-collapse collapse ";
|
||||
if ($i == 0){ $html .= "in"; } else { $html .= "out"; }
|
||||
$html .= "' role='tabpanel'><div class='panel-body'><p>".$panel['body']."</p></div>";
|
||||
$html .= "</div></div>";
|
||||
$i++;
|
||||
}
|
||||
$html .= "</div>";
|
||||
return $html;
|
||||
|
||||
}
|
||||
}
|
||||
39
application/third_party/Sioen/Types/BaseConverter.php
vendored
Executable file
39
application/third_party/Sioen/Types/BaseConverter.php
vendored
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
class BaseConverter implements ConverterInterface
|
||||
{
|
||||
/**
|
||||
* The options we use for html to markdown
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = array(
|
||||
'header_style' => 'atx',
|
||||
'bold_style' => '__',
|
||||
'italic_style' => '_',
|
||||
);
|
||||
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
$html = $node->ownerDocument->saveXML($node);
|
||||
|
||||
return array(
|
||||
'type' => 'text',
|
||||
'data' => array(
|
||||
'text' => ' ' . $this->htmlToMarkdown($html)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
|
||||
return Markdown::defaultTransform($data['text']);
|
||||
}
|
||||
|
||||
protected function htmlToMarkdown($html)
|
||||
{
|
||||
$markdown = new \HTML_To_Markdown($html, $this->options);
|
||||
return $markdown->output();
|
||||
}
|
||||
}
|
||||
52
application/third_party/Sioen/Types/BlockquoteConverter.php
vendored
Executable file
52
application/third_party/Sioen/Types/BlockquoteConverter.php
vendored
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
class BlockquoteConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
// check if the quote contains a cite
|
||||
$cite = '';
|
||||
|
||||
foreach ($node->childNodes as $child) {
|
||||
// if it contains a 'cite' node, we should add it in the cite property
|
||||
if ($child->nodeName == 'cite') {
|
||||
$html = $child->ownerDocument->saveXML($child);
|
||||
$html = preg_replace('/<(\/|)cite>/i', '', $html);
|
||||
$child->parentNode->removeChild($child);
|
||||
$cite = ' ' . $this->htmlToMarkdown($html);
|
||||
}
|
||||
}
|
||||
|
||||
// we use the remaining html to create the remaining text
|
||||
$html = $node->ownerDocument->saveXML($node);
|
||||
$html = preg_replace('/<(\/|)blockquote>/i', '', $html);
|
||||
|
||||
return array(
|
||||
'type' => 'quote',
|
||||
'data' => array(
|
||||
'text' => ' ' . $this->htmlToMarkdown($html),
|
||||
'cite' => $cite
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
$text = $data['text'];
|
||||
$html = '<blockquote>';
|
||||
$html .= Markdown::defaultTransform($text);
|
||||
|
||||
// Add the cite if necessary
|
||||
if (isset($data['cite']) && !empty($data['cite'])) {
|
||||
// remove the indent thats added by Sir Trevor
|
||||
$cite = ltrim($data['cite'], '>');
|
||||
$html .= '<cite>' . Markdown::defaultTransform($cite) . '</cite>';
|
||||
}
|
||||
|
||||
$html .= '</blockquote>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
27
application/third_party/Sioen/Types/ButtonConverter.php
vendored
Executable file
27
application/third_party/Sioen/Types/ButtonConverter.php
vendored
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ButtonConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
return array(
|
||||
'type' => 'image',
|
||||
'data' => array(
|
||||
'file' => array(
|
||||
'url' => $node->getAttribute('src')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
if ($data['is_block']==1){
|
||||
$block=" btn-block";
|
||||
} else {
|
||||
$block = "";
|
||||
}
|
||||
return '<a href="' . $data['url'] . '" class="btn ' . $data['style'] . ' ' . $data['size'] . $block .'">' . $data['html'] . '</a>' . "\n";
|
||||
}
|
||||
}
|
||||
35
application/third_party/Sioen/Types/CodeConverter.php
vendored
Executable file
35
application/third_party/Sioen/Types/CodeConverter.php
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
class CodeConverter implements ConverterInterface
|
||||
{
|
||||
/**
|
||||
* The options we use for html to markdown
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
$html = $node->ownerDocument->saveXML($node);
|
||||
|
||||
return array(
|
||||
'type' => 'text',
|
||||
'data' => array(
|
||||
'text' => ' ' . $this->htmlToMarkdown($html)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
print_r($data);
|
||||
die();
|
||||
return Markdown::defaultTransform($data['text']);
|
||||
}
|
||||
|
||||
protected function htmlToMarkdown($html)
|
||||
{
|
||||
$markdown = new \HTML_To_Markdown($html, $this->options);
|
||||
return $markdown->output();
|
||||
}
|
||||
}
|
||||
33
application/third_party/Sioen/Types/ColumnsConverter.php
vendored
Executable file
33
application/third_party/Sioen/Types/ColumnsConverter.php
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class ColumnsConverter extends BaseConverter implements ConverterInterface {
|
||||
|
||||
public function toJson(\DOMElement $node) {
|
||||
return array(
|
||||
'type' => 'image',
|
||||
'data' => array(
|
||||
'file' => array(
|
||||
'url' => $node->getAttribute('src')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data) {
|
||||
$html = "<div class='row'>";
|
||||
// echo "<pre>";
|
||||
// print_r($data);
|
||||
// die();
|
||||
|
||||
foreach ($data['columns'] as $column) {
|
||||
$html .= "<div class='col-md-".$column['width']."'>";
|
||||
$converter = new Converter();
|
||||
$HTMLContent = $converter->toHtml(json_encode(array("data"=>$column["blocks"])));
|
||||
$html .= $HTMLContent;
|
||||
$html .= "</div>";
|
||||
}
|
||||
$html .= "</div>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
9
application/third_party/Sioen/Types/ConverterInterface.php
vendored
Executable file
9
application/third_party/Sioen/Types/ConverterInterface.php
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
interface ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node);
|
||||
public function toHtml(array $data);
|
||||
}
|
||||
24
application/third_party/Sioen/Types/HeadingConverter.php
vendored
Executable file
24
application/third_party/Sioen/Types/HeadingConverter.php
vendored
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class HeadingConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
$html = $node->ownerDocument->saveXML($node);
|
||||
|
||||
// remove the h2 tags from the text. We just need the inner text.
|
||||
$html = preg_replace('/<(\/|)h2>/i', '', $html);
|
||||
|
||||
return array(
|
||||
'type' => 'heading',
|
||||
'data' => array(
|
||||
'text' => ' ' . $this->htmlToMarkdown($html)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
return "<".$data['heading'].">".stripslashes($data['text']) . "</".$data['heading'].">";
|
||||
}
|
||||
}
|
||||
69
application/third_party/Sioen/Types/IframeConverter.php
vendored
Executable file
69
application/third_party/Sioen/Types/IframeConverter.php
vendored
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
|
||||
class IframeConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
$html = $node->ownerDocument->saveXML($node);
|
||||
|
||||
// youtube or vimeo
|
||||
if (preg_match('~//www.youtube.com/embed/([^/\?]+).*\"~si', $html, $matches)) {
|
||||
return array(
|
||||
'type' => 'video',
|
||||
'data' => array(
|
||||
'source' => 'youtube',
|
||||
'remote_id' => $matches[1]
|
||||
)
|
||||
);
|
||||
} elseif (preg_match('~//player.vimeo.com/video/([^/\?]+).*\?~si', $html, $matches)) {
|
||||
return array(
|
||||
'type' => 'video',
|
||||
'data' => array(
|
||||
'source' => 'vimeo',
|
||||
'remote_id' => $matches[1]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
|
||||
// youtube video's
|
||||
$source = $data['source'];
|
||||
$remoteId = $data['remote_id'];
|
||||
|
||||
if ($source == 'youtube') {
|
||||
$html = '<div class="embed-responsive embed-responsive-16by9"><iframe src="//www.youtube.com/embed/' . $remoteId . '?rel=0" ';
|
||||
$html .= 'frameborder="0" allowfullscreen></iframe></div>' . "\n";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// vimeo videos
|
||||
if ($source == 'vimeo') {
|
||||
$html = '<div class="embed-responsive embed-responsive-16by9"><iframe src="//player.vimeo.com/video/' . $remoteId;
|
||||
$html .= '?title=0&byline=0" frameborder="0"></iframe></div>' . "\n";
|
||||
|
||||
return $html;
|
||||
}
|
||||
//dailymotion
|
||||
if ($source == 'dailymotion') {
|
||||
$html = '<div class="embed-responsive embed-responsive-16by9"><iframe src="//www.dailymotion.com/embed/video/' . $remoteId . '" ';
|
||||
$html .= 'frameborder="0" allowfullscreen></iframe></div>' . "\n";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// vine
|
||||
if ($source == 'vine') {
|
||||
$html = '<div class="embed-responsive embed-responsive-16by9"><iframe src="/vine.co/v/' . $remoteId;
|
||||
$html .= '/embed/simple" frameborder="0"></iframe><script async src="http://platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>' . "\n";
|
||||
|
||||
return $html;
|
||||
}
|
||||
// fallback
|
||||
return '';
|
||||
}
|
||||
}
|
||||
25
application/third_party/Sioen/Types/IframeExtendedConverter.php
vendored
Executable file
25
application/third_party/Sioen/Types/IframeExtendedConverter.php
vendored
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
|
||||
class IframeExtendedConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
$html = $node->ownerDocument->saveXML($node);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
$height = $data['height'] * 1.3;
|
||||
if ($data['width'] > $height){
|
||||
$size = "embed-responsive-16by9";
|
||||
} else {
|
||||
$size = "embed-responsive-4by3";
|
||||
}
|
||||
$html = '<div class="embed-responsive '.$size.'"><iframe src="'.$data['src'].'" width="'.$data['width'].'" height="'.$data['height'].'" frameborder="0"></iframe></div>' . "\n";
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
22
application/third_party/Sioen/Types/ImageConverter.php
vendored
Executable file
22
application/third_party/Sioen/Types/ImageConverter.php
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ImageConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
return array(
|
||||
'type' => 'image',
|
||||
'data' => array(
|
||||
'file' => array(
|
||||
'url' => $node->getAttribute('src')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
return '<img class="img-responsive" src="' . $data['file']['url'] . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
31
application/third_party/Sioen/Types/ImageExtendedConverter.php
vendored
Executable file
31
application/third_party/Sioen/Types/ImageExtendedConverter.php
vendored
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class ImageExtendedConverter implements ConverterInterface
|
||||
{
|
||||
/**
|
||||
* The options we use for html to markdown
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
$html = $node->ownerDocument->saveXML($node);
|
||||
|
||||
return array(
|
||||
'type' => 'text',
|
||||
'data' => array(
|
||||
'text' => ' ' . $this->htmlToMarkdown($html)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toHtml(array $data)
|
||||
{
|
||||
if (($data['source'] == "") || ($data['source'] == "http://")){
|
||||
return '<img class="img-responsive" src="' . $data['file']['url'] . '" alt="' . $data['caption'] . '" />' . "\n";
|
||||
} else {
|
||||
return '<a href="' . $data['source'] . '" target="_blank"><img class="img-responsive" src="' . $data['file']['url'] . '" alt="' . $data['caption'] . '" /></a>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
20
application/third_party/Sioen/Types/ListConverter.php
vendored
Executable file
20
application/third_party/Sioen/Types/ListConverter.php
vendored
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ListConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
public function toJson(\DOMElement $node)
|
||||
{
|
||||
$markdown = $this->htmlToMarkdown($node->ownerDocument->saveXML($node));
|
||||
|
||||
// we need a space in the beginning of each line
|
||||
$markdown = ' ' . str_replace("\n", "\n ", $markdown);
|
||||
|
||||
return array(
|
||||
'type' => 'list',
|
||||
'data' => array(
|
||||
'text' => $markdown,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
6
application/third_party/Sioen/Types/ParagraphConverter.php
vendored
Executable file
6
application/third_party/Sioen/Types/ParagraphConverter.php
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ParagraphConverter extends BaseConverter implements ConverterInterface
|
||||
{
|
||||
}
|
||||
10
application/third_party/Sioen/Types/index.html
vendored
Executable file
10
application/third_party/Sioen/Types/index.html
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
application/third_party/Sioen/index.html
vendored
Executable file
10
application/third_party/Sioen/index.html
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
11
application/third_party/index.html
vendored
Executable file
11
application/third_party/index.html
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user