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

Wrong context for 'continue' #42

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion administrator/components/com_media/controllers/folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function create()
if (in_array(false, $result, true)) {
// There are some errors in the plugins
JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
continue;
return false;
}

JFolder::create($path);
Expand Down
10 changes: 9 additions & 1 deletion administrator/language/en-GB/en-GB.plg_editors_codemirror.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ PLG_CODEMIRROR_FIELD_TABMODE_LABEL="Tab mode"
PLG_CODEMIRROR_FIELD_VALUE_TABMODE_INDENT="Indent"
PLG_CODEMIRROR_FIELD_VALUE_TABMODE_SHIFT="Shift"
PLG_CODEMIRROR_XML_DESCRIPTION="This plugin loads the CodeMirror editor."
PLG_EDITORS_CODEMIRROR="Editor - CodeMirror"
PLG_EDITORS_CODEMIRROR="Editor - CodeMirror"

PLG_CODEMIRROR_FIELD_MINHEIGHT_DESC="The minimum height of the editor display in pixels."
PLG_CODEMIRROR_FIELD_MINHEIGHT_LABEL="Minimum height (px)"
PLG_CODEMIRROR_FIELD_FONTSIZE_DESC="The size of the font in the editor."
PLG_CODEMIRROR_FIELD_FONTSIZE_LABEL="Font size (px)"
PLG_CODEMIRROR_FIELD_FONT_DESC="The font to use in the editor. If not installed, will be loaded from http://www.google.com/webfonts"
PLG_CODEMIRROR_FIELD_FONT_LABEL="Font"
PLG_CODEMIRROR_FIELD_VALUE_FONT_DEFAULT="Browser Default"
6 changes: 6 additions & 0 deletions media/editors/codemirror/css/codemirror.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
font-size: 10pt;
font-family: monospace;
padding-top: .4em;
}

.CodeMirror-wrapping
{
box-shadow: inset 0px 0px 3px #333;
background: #fafafa;
}
65 changes: 63 additions & 2 deletions plugins/editors/codemirror/codemirror.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons
$width .= 'px';
}

// if height is given in pixels, compare it to the minheight param and keep the bigger of the two
$height = trim($height, 'px');
$minheight = (int) $this->params->get('editor_minheight', 100);
if (is_numeric($height)) {
$height = max($height, $minheight);
$height .= 'px';
}

Expand Down Expand Up @@ -174,6 +178,7 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons
{
$style = JURI::root(true).'/'.$this->_basePath.'/css/'.$style;
}
$styleSheet[] = $this->getFontStyleSheet();

$options = new stdClass;

Expand All @@ -194,13 +199,16 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons
$options->tabMode = 'shift';
}

$editorStyles = $this->getEditorStyles();

$html = array();
$html[] = "<textarea name=\"$name\" id=\"$id\" cols=\"$col\" rows=\"$row\">$content</textarea>";
$html[] = $buttons;
$html[] = '<script type="text/javascript">';
$html[] = '(function() {';
$html[] = 'var editor = CodeMirror.fromTextArea("'.$id.'", '.json_encode($options).');';
$html[] = 'Joomla.editors.instances[\''.$id.'\'] = editor;';
$html[] = ' var setStyles = function() { Object.append( editor.editor.container.style, '.json_encode($editorStyles).'); }';
$html[] = ' var editor = CodeMirror.fromTextArea("'.$id.'", Object.merge('.json_encode($options).',{onLoad:setStyles}));';
$html[] = ' Joomla.editors.instances[\''.$id.'\'] = editor;';
$html[] = '})()';
$html[] = '</script>';

Expand Down Expand Up @@ -258,4 +266,57 @@ protected function _displayButtons($name, $buttons, $asset, $author)

return implode("\n", $html);
}

/**
* Gets the url of a font stylesheet (from google web fonts) based on param values
*
* @return string $styleSheet a url (or empty string)
* @access protected
*/
protected function getFontStyleSheet()
{
$key = $this->params->get('font_family', 0);
$styleSheets = array(
'anonymous_pro' => 'http://fonts.googleapis.com/css?family=Anonymous+Pro:400,700,400italic,700italic&subset=latin,latin-ext&v2',
'cousine' => 'http://fonts.googleapis.com/css?family=Cousine:400,700italic,700,400italic&subset=latin,latin-ext&v2',
'droid_sans_mono' => 'http://fonts.googleapis.com/css?family=Droid+Sans+Mono&subset=latin,latin-ext&v2',
'inconsolata' => 'http://fonts.googleapis.com/css?family=Inconsolata&subset=latin,latin-ext&v2',
'lekton' => 'http://fonts.googleapis.com/css?family=Lekton:400,400italic,700&subset=latin,latin-ext&v2',
'nova_mono' => 'http://fonts.googleapis.com/css?family=Nova+Mono&subset=latin,latin-ext&v2',
'ubuntu_mono' => 'http://fonts.googleapis.com/css?family=Ubuntu+Mono&subset=latin,latin-ext&v2',
'vt323' => 'http://fonts.googleapis.com/css?family=VT323&subset=latin,latin-ext&v2'
);

return isset($styleSheets[$key]) ? $styleSheets[$key] : '';
}

/**
* Gets style declarations for using the select font and size from params
* returning as array for json encoding
*
* @return array
* @access protected
*/
protected function getEditorStyles()
{
$key = $this->params->get('font_family', 0);
$fonts = array(
'anonymous_pro' => 'Anonymous Pro, monospace',
'cousine' => 'Cousine, monospace',
'droid_sans_mono' => 'Droid Sans Mono, monospace',
'inconsolata' => 'Inconsolata, monospace',
'lekton' => 'Tekton, monospace',
'nova_mono' => 'Nova Mono, monospace',
'ubuntu_mono' => 'Ubuntu Mono, monospace',
'vt323' => 'VT323, monospace'
);

$size = (int) $this->params->get('font_size', 10);

$styles = array(
'font-family' => isset($fonts[$key]) ? $fonts[$key] : 'monospace',
'font-size' => $size.'px'
);
return $styles;
}
}
29 changes: 29 additions & 0 deletions plugins/editors/codemirror/codemirror.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@
<option value="indent">PLG_CODEMIRROR_FIELD_VALUE_TABMODE_INDENT</option>
<option value="shift">PLG_CODEMIRROR_FIELD_VALUE_TABMODE_SHIFT</option>
</field>

<field name="editor_minheight" type="integer"
first="200" last="800" step="50" default="400"
description="PLG_CODEMIRROR_FIELD_MINHEIGHT_DESC"
label="PLG_CODEMIRROR_FIELD_MINHEIGHT_LABEL"
/>

<field name="font_size" type="integer"
first="6" last="16" step="1" default="10"
description="PLG_CODEMIRROR_FIELD_FONTSIZE_DESC"
label="PLG_CODEMIRROR_FIELD_FONTSIZE_LABEL"
/>

<field name="font_family" type="list"
default="0"
description="PLG_CODEMIRROR_FIELD_FONT_DESC"
label="PLG_CODEMIRROR_FIELD_FONT_LABEL"
>
<option value="0">PLG_CODEMIRROR_FIELD_VALUE_FONT_DEFAULT</option>
<option value="anonymous_pro">Anonymous Pro</option>
<option value="cousine">Cousine</option>
<option value="droid_sans_mono">Droid Sans Mono</option>
<option value="inconsolata">Inconsolata</option>
<option value="lekton">Lekton</option>
<option value="nova_mono">Nova Mono</option>
<option value="ubuntu_mono">Ubuntu Mono</option>
<option value="vt323">VT323</option>
</field>

</fieldset>

</fields>
Expand Down