Skip to content

Commit

Permalink
Setup viewer for ModuleController, move locally scoped jquery and ent…
Browse files Browse the repository at this point in the history
…wine into preview handler js
  • Loading branch information
Conrad committed Jul 25, 2016
1 parent e39d54e commit fbe72cb
Show file tree
Hide file tree
Showing 5 changed files with 2,298 additions and 8 deletions.
3 changes: 3 additions & 0 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Page:
extensions:
- ContentModule_PageExtension
Page_Controller:
extensions:
- ContentModule_PageController_Extension
SiteConfig:
extensions:
- ContentModuleSiteConfigExtension
13 changes: 13 additions & 0 deletions code/controllers/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ public function init()
parent::init();
}

/**
* Return an SSViewer object to process the data
*
* Overwrite defaut viewer by disabling requirements
*
* @return SSViewer The viewer identified being the default handler for this Controller/Action combination
*/
public function getViewer($action) {
$viewer = new SSViewer(array_reverse(ClassInfo::ancestry($this->data()->class)));
$viewer->includeRequirements(false);
return $viewer;
}

public function handleRequest(SS_HTTPRequest $request, DataModel $model)
{
return parent::handleRequest($request, $model);
Expand Down
6 changes: 2 additions & 4 deletions code/model/ContentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function forTemplate()
$controller->setFailover($this);
}

$html = $controller->renderWith(array_reverse(ClassInfo::ancestry($this->class)));
$html = $controller->renderWith($controller->getViewer(''));

//check if we are in editor mode, if so inject html to handle modules
if ($this->getIsEditorMode()) {
Expand Down Expand Up @@ -1187,9 +1187,7 @@ public function injectModuleEditor(HTMLText $html)
//clear the errors
libxml_clear_errors();

$html->setValue($newHTML);

return $html;
return DBField::create_field('HTMLText', $newHTML);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions javascript/ContentModuleField.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
e.preventDefault();
e.stopPropagation();

var name = this.attr('name');console.log(this, name);
var name = this.attr('name');
var action = name.substring(name.indexOf('_') + 1, name.lastIndexOf('_'));

this.closest('.content-module').submitModule(action);
Expand All @@ -631,7 +631,7 @@
e.preventDefault();
e.stopPropagation();

var name = this.attr('name');console.log(this, name);
var name = this.attr('name');
var action = name.substring(name.indexOf('_') + 1, name.lastIndexOf('_'));

var contentModule = this.closest('.content-module');
Expand Down
2,280 changes: 2,278 additions & 2 deletions javascript/VisualEditor.PreviewHandler.js

Large diffs are not rendered by default.

0 comments on commit fbe72cb

Please sign in to comment.