Changed HTML editor processing, added TinyMCE

This commit is contained in:
Deon George
2013-11-20 13:26:02 +11:00
parent 610c223cb8
commit 1ec370f07a
82 changed files with 598 additions and 19 deletions

View File

@@ -88,12 +88,67 @@ abstract class lnApp_Form extends Kohana_Form {
if (! isset($attributes['id']))
$attributes['id'] = preg_replace('/[\[\]]/','_',$name);
if (! isset($attributes['nowysihtml']))
Script::factory()
->type('stdin')
->data('$("#'.$attributes['id'].'").wysihtml5();');
else
unset($attributes['wysihtml']);
if (isset($attributes['editor'])) {
switch ($attributes['editor']) {
case 'tinymce':
Script::factory()
->type('file')
->data('media/vendor/tinymce/js/tinymce/jquery.tinymce.min.js');
Script::factory()
->type('stdin')
->data('$("#'.$attributes['id'].'").tinymce({
script_url : "'.URL::site('media/vendor/tinymce/js/tinymce/tinymce.min.js').'",
theme : "modern",
plugins: [ "code","link","image","preview","table" ],
menubar: "",
toolbar: "undo redo | styleselect | bold italic | link image | table | preview | code",
});');
break;
case 'wysihtml5':
Style::factory()
->type('file')
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.css');
Script::factory()
->type('file')
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/libs/js/wysihtml5-0.3.0_rc2.min.js');
Script::factory()
->type('file')
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.min.js');
Script::factory()
->type('stdin')
->data('$("#'.$attributes['id'].'").wysihtml5({
html: true,
parserRules: {
tags: {
p: {},
strong: {},
table: {},
tbody: {},
thead: {},
tr: {},
td: {
check_attributes: {
colspan: "numbers",
rowspan: "numbers",
}
}
}
}
});');
break;
default:
throw new Kohana_Exception('Unknown editor :editor for textarea',array(':editor'=>$attributes['editor']));
}
unset($attributes['edit']);
}
return sprintf(static::_controlgroup($name,$attributes),parent::textarea($name,$body,$attributes,$double_encode));
}

View File

@@ -20,13 +20,13 @@ abstract class lnApp_Table {
private $po = NULL; // If we are paging the results, this is the page we are displaying
private $page = FALSE; // If we should page the results
private $page_rows = 0; // Number of rows per page
private $prepend = array(); // Our datafomrating that we need to use
private $prepend_vals = array(); // Our datafomrating that we need to use
private $prepend = array(); // Our data formating that we need to use, prepended to the value
private $postproc = array(); // Our data formating that we need to use after the value is determined
private $select = array(); // Our select form details
public function __toString() {
try {
return (string) $this->render();
return (string)$this->render();
} catch (Exception $e) {
return $e->getMessage();
@@ -97,6 +97,22 @@ abstract class lnApp_Table {
}
}
if (isset($this->postproc[$key]) and $x) {
foreach ($this->postproc[$key] as $act => $data) {
switch ($act) {
case 'trim':
if (strlen($x) > $data) {
$x = sprintf('<abbr title="%s">%s</abbr>',$x,substr($x,0,$data-3).str_repeat('.',3));
}
break;
default:
throw HTTP_Exception::factory(501,'Unknown action :action',array(':action'=>$act));
}
}
}
return $x;
}
@@ -132,6 +148,12 @@ abstract class lnApp_Table {
return $this;
}
public function postproc($cols) {
$this->postproc = $cols;
return $this;
}
private function process() {
$result = array();