Permalink
Browse files

ENHANCEMENT Shortcodes now support commas as delimiter for attributes…

… (thanks aoneil for help with the regex!) (trac #6868)

BUGFIX HtmlEditorField not inserting shortcodes correctly (trac #6868)
  • Loading branch information...
1 parent c59c717 commit 49267dbbc46422d27cfaa81bc131c2dea679df9f @halkyon halkyon committed Mar 9, 2012
Showing with 7 additions and 8 deletions.
  1. +2 −2 javascript/HtmlEditorField.js
  2. +2 −3 parsers/ShortcodeParser.php
  3. +3 −3 tests/parsers/ShortcodeParserTest.php
@@ -370,7 +370,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
// All other attributes
switch(this.find(':input[name=LinkType]:checked').val()) {
case 'internal':
- href = '[sitetree_link id=' + this.find(':input[name=internal]').val() + ']';
+ href = '[sitetree_link,id=' + this.find(':input[name=internal]').val() + ']';
if(anchor) href += '#' + anchor;
break;
@@ -379,7 +379,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
break;
case 'file':
- href = '[file_link id=' + this.find(':input[name=file]').val() + ']';
+ href = '[file_link,id=' + this.find(':input[name=file]').val() + ']';
target = '_blank';
break;
@@ -170,10 +170,9 @@ protected function handleShortcode($matches) {
if($prefix == '[' && $suffix == ']') {
return substr($matches[0], 1, -1);
}
-
$attributes = array(); // Parse attributes into into this array.
- if(preg_match_all('/(\w+) *= *(?:([\'"])(.*?)\\2|([^ "\'>]+))/', $matches[3], $match, PREG_SET_ORDER)) {
+ if(preg_match_all('/(\w+) *= *(?:([\'"])(.*?)\\2|([^ ,"\'>]+))/', $matches[3], $match, PREG_SET_ORDER)) {
foreach($match as $attribute) {
if(!empty($attribute[4])) {
$attributes[strtolower($attribute[1])] = $attribute[4];
@@ -186,4 +185,4 @@ protected function handleShortcode($matches) {
return $prefix . call_user_func($this->shortcodes[$shortcode], $attributes, $matches[5], $this, $shortcode) . $suffix;
}
-}
+}
@@ -82,14 +82,14 @@ public function testShortcodeEscaping() {
}
public function testUnquotedArguments() {
- $this->assertEquals('', $this->parser->parse('[test_shortcode foo=bar baz = buz]'));
+ $this->assertEquals('', $this->parser->parse('[test_shortcode,foo=bar,baz = buz]'));
$this->assertEquals(array('foo' => 'bar', 'baz' => 'buz'), $this->arguments);
}
public function testSelfClosingTag() {
$this->assertEquals (
'morecontent',
- $this->parser->parse('[test_shortcode id="1"/]more[test_shortcode id="2"]content[/test_shortcode]'),
+ $this->parser->parse('[test_shortcode,id="1"/]more[test_shortcode,id="2"]content[/test_shortcode]'),
'Assert that self-closing tags are respected during parsing.'
);
@@ -109,4 +109,4 @@ public function shortcodeSaver($arguments, $content = null, $parser, $tagName =
return $content;
}
-}
+}

0 comments on commit 49267db

Please sign in to comment.