Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symphony 2.4 compatibility #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/symphony.ckeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jQuery(document).ready(function () {
{
if(ckeditor_presets[i].class == myClassName)
{
var info = ckeditor_presets[i];
//var info = ckeditor_presets[i];
var info = jQuery.extend(true, {}, ckeditor_presets[i]);
info.toolbar.unshift(formatBlock);
ck_configurationData.toolbar = info.toolbar;
ck_configurationData.resize_enabled = info.resize;
Expand Down
62 changes: 49 additions & 13 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,21 @@ public function appendPresets($context)
}
$this->sections[] = $a;
}



/*

LINK TEMPLATES

*/

$fieldset->appendChild(new XMLElement('p', __('Link templates:'), array('class' => 'label')));

$linkOuter = new XMLElement('div', null, array(
'class' => 'frame ckeditor-duplicator'
));

$ol = new XMLElement('ol');
$ol->setAttribute('class', 'ckeditor-duplicator');

$templates = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_link_templates`;');
if(!is_array($pages)) $pages = array($pages);
Expand All @@ -130,13 +141,23 @@ public function appendPresets($context)
$duplicator = $this->__buildDuplicatorItem($page, NULL);
$ol->appendChild($duplicator);
}

$fieldset->appendChild($ol);

// Plugin presets:

$linkOuter->appendChild($ol);
$fieldset->appendChild($linkOuter);

/*

PLUGIN PRESENTS

*/
$fieldset->appendChild(new XMLElement('p', __('Plugin presets:'), array('class' => 'label')));

$out_wrapper = new XMLElement('div', null, array(
'class' => 'frame ckeditor-duplicator',
'id' => 'ckeditor-duplicator'
));

$ol = new XMLElement('ol');
$ol->setAttribute('class', 'ckeditor-duplicator');

// Create template:
$template = new XMLElement('li', null, array('class' => 'template'));
Expand All @@ -150,11 +171,15 @@ public function appendPresets($context)
$ol->appendChild($template);

// Append all the fields:
$presets = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_presets');
$presets = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_presets`');
$index = 0;

foreach($presets as $preset)
{
$template = new XMLElement('li');

$template->setAttribute('class','instance expanded');

$template->appendChild(new XMLElement('header', '<h3>'.$preset['name'].'</h3>'));
$template->appendChild(Widget::Label(__('Name'), Widget::Input('ckeditor_presets['.$index.'][name]', $preset['name'])));
$template->appendChild(Widget::Label(__('Toolbar'),
Expand All @@ -172,8 +197,10 @@ public function appendPresets($context)
$ol->appendChild($template);
$index++;
}

$fieldset->appendChild($ol);


$out_wrapper->appendChild($ol);
$fieldset->appendChild($out_wrapper);

// Styles:
$fieldset->appendChild(new XMLElement('p', __('Styles: (one style per line: <code>h3.example { color: #f00; background: #0f0; }</code>) Class name is converted to name (h3.hello-world = Hello World).'), array('class'=>'label')));
Expand Down Expand Up @@ -345,20 +372,29 @@ public function install()
) ENGINE = MYISAM ;
");

// Fill default presets:
Symphony::Database()->query("
/*
Fill default presets

Only if table is empty (prevents loads being created if installs fail

*/
$presets = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_presets`');
if(count($presets) < 1){

Symphony::Database()->query("
INSERT INTO `tbl_ckeditor_presets` (`name`, `toolbar`, `plugins`, `resize`, `outline`) VALUES
('Minimal', '[''Bold'', ''Italic'', ''Strike'', ''-'', ''Subscript'', ''Superscript''],\r\n[''Link'', ''Unlink''],\r\n[''Source'']', NULL, NULL, NULL),
('Normal', '[''Bold'', ''Italic'', ''Strike'', ''-'', ''Subscript'', ''Superscript''],\r\n[''NumberedList'', ''BulletedList'', ''-'', ''Outdent'', ''Indent'', ''Blockquote''],\r\n[''Image'', ''oembed''],[''Link'', ''Unlink''],\r\n[''HorizontalRule''],\r\n[''Source'', ''Maximize'']', NULL, 1, 1),
('Full', '{ name: ''document'', items : [ ''Source'',''-'',''Save'',''NewPage'',''DocProps'',''Preview'',''Print'',''-'',''Templates'' ] },\r\n { name: ''clipboard'', items : [ ''Cut'',''Copy'',''Paste'',''PasteText'',''PasteFromWord'',''-'',''Undo'',''Redo'' ] },\r\n { name: ''editing'', items : [ ''Find'',''Replace'',''-'',''SelectAll'',''-'',''SpellChecker'', ''Scayt'' ] },\r\n { name: ''forms'', items : [ ''Form'', ''Checkbox'', ''Radio'', ''TextField'', ''Textarea'', ''Select'', ''Button'', ''ImageButton'', ''HiddenField'' ] },\r\n ''/'',\r\n { name: ''basicstyles'', items : [ ''Bold'',''Italic'',''Underline'',''Strike'',''Subscript'',''Superscript'',''-'',''RemoveFormat'' ] },\r\n { name: ''paragraph'', items : [ ''NumberedList'',''BulletedList'',''-'',''Outdent'',''Indent'',''-'',''Blockquote'',''CreateDiv'',''-'',''JustifyLeft'',''JustifyCenter'',''JustifyRight'',''JustifyBlock'',''-'',''BidiLtr'',''BidiRtl'' ] },\r\n { name: ''links'', items : [ ''Link'',''Unlink'',''Anchor'' ] },\r\n { name: ''insert'', items : [ ''Image'',''Flash'',''Table'',''HorizontalRule'',''Smiley'',''SpecialChar'',''PageBreak'' ] },\r\n ''/'',\r\n { name: ''styles'', items : [ ''Styles'',''Format'',''Font'',''FontSize'' ] },\r\n { name: ''colors'', items : [ ''TextColor'',''BGColor'' ] },\r\n { name: ''tools'', items : [ ''Maximize'', ''ShowBlocks'',''-'',''About'' ] }', NULL, 1, 1);
");

}

// Delete formatter files:
$formatters = glob(EXTENSIONS.'/ckeditor/text-formatters/formatter.*.php');
foreach($formatters as $formatter) { unlink($formatter); }

// Create it all new:
$presets = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_presets`;');
foreach($presets as $preset)
{
unset($preset['id']);
Expand Down