diff --git a/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.js b/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.js
index 32ff000f..0332fc71 100644
--- a/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.js
+++ b/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.js
@@ -1,17 +1,22 @@
$(document).ready(function() {
+
+ if(!ProcessWire.config.ProcessPageEditLink) return;
+
+ var cfg = ProcessWire.config.ProcessPageEditLink;
var options = {
- selectStartLabel: ProcessWire.config.ProcessPageEditLink.selectStartLabel,
- selectSelectLabel: ProcessWire.config.ProcessPageEditLink.selectStartLabel,
- langID: ProcessWire.config.ProcessPageEditLink.langID
+ selectStartLabel: cfg.selectStartLabel,
+ selectSelectLabel: cfg.selectStartLabel,
+ langID: cfg.langID
// openPageIDs: config.ProcessPageEditLink.openPageIDs
- };
+ };
+
var options2 = {
selectStartLabel: options.selectStartLabel,
selectSelectLabel: options.selectStartLabel,
langID: options.langID,
- rootPageID: ProcessWire.config.ProcessPageEditLink.pageID
- };
+ rootPageID: cfg.pageID
+ };
var selectedPageData = {
id: 0,
@@ -45,7 +50,7 @@ $(document).ready(function() {
}
function absoluteToRelativePath(path) {
- if(ProcessWire.config.ProcessPageEditLink.urlType == 0) return path;
+ if(cfg.urlType == 0) return path;
function slashesToRelative(url) {
url = url.replace(/\//g, '../');
@@ -55,36 +60,36 @@ $(document).ready(function() {
var url;
- if(path === ProcessWire.config.ProcessPageEditLink.pageUrl) {
+ if(path === cfg.pageUrl) {
// account for the link to self
path = './';
- if(!ProcessWire.config.ProcessPageEditLink.slashUrls) path += ProcessWire.config.ProcessPageEditLink.pageName;
+ if(!cfg.slashUrls) path += cfg.pageName;
- } else if(path.indexOf(ProcessWire.config.ProcessPageEditLink.pageUrl) === 0) {
+ } else if(path.indexOf(cfg.pageUrl) === 0) {
// linking to child of current page
- path = path.substring(ProcessWire.config.ProcessPageEditLink.pageUrl.length);
- if(!ProcessWire.config.ProcessPageEditLink.slashUrls) path = ProcessWire.config.ProcessPageEditLink.pageName + path;
+ path = path.substring(cfg.pageUrl.length);
+ if(!cfg.slashUrls) path = cfg.pageName + path;
- } else if(ProcessWire.config.ProcessPageEditLink.pageUrl.indexOf(path) === 0) {
+ } else if(cfg.pageUrl.indexOf(path) === 0) {
// linking to a parent of the current page
- url = ProcessWire.config.ProcessPageEditLink.pageUrl.substring(path.length);
+ url = cfg.pageUrl.substring(path.length);
if(url.indexOf('/') != -1) {
url = slashesToRelative(url);
} else {
url = './';
}
path = url;
- } else if(path.indexOf(ProcessWire.config.ProcessPageEditLink.rootParentUrl) === 0) {
+ } else if(path.indexOf(cfg.rootParentUrl) === 0) {
// linking to a sibling or other page in same branch (but not a child)
- url = path.substring(ProcessWire.config.ProcessPageEditLink.rootParentUrl.length);
+ url = path.substring(cfg.rootParentUrl.length);
var url2 = url;
url = slashesToRelative(url) + url2;
path = url;
- } else if(ProcessWire.config.ProcessPageEditLink.urlType == 2) { // 2=relative for all
+ } else if(cfg.urlType == 2) { // 2=relative for all
// page in a different tree than current
// traverse back to root
- url = ProcessWire.config.ProcessPageEditLink.pageUrl.substring(config.urls.root.length);
+ url = cfg.pageUrl.substring(ProcessWire.config.urls.root.length);
url = slashesToRelative(url);
path = path.substring(ProcessWire.config.urls.root.length);
path = url + path;
@@ -154,7 +159,7 @@ $(document).ready(function() {
$link.attr('title', val);
}
- if(ProcessWire.config.ProcessPageEditLink.noLinkTextEdit) {
+ if(cfg.noLinkTextEdit) {
// link text editing disabled
} else if($linkText.length && $linkText.val().length) {
$link.text($linkText.val());
@@ -259,15 +264,15 @@ $(document).ready(function() {
if (!$this.hasClass('external-link')) {
icon().removeClass(allIcons).addClass(extLinkIcon);
$this.addClass('external-link');
- var extLinkTarget = ProcessWire.config.ProcessPageEditLink.extLinkTarget;
+ var extLinkTarget = cfg.extLinkTarget;
if (extLinkTarget.length > 0) {
$("#link_target").val(extLinkTarget);
}
- var extLinkRel = ProcessWire.config.ProcessPageEditLink.extLinkRel;
+ var extLinkRel = cfg.extLinkRel;
if (extLinkRel.length > 0) {
$("#link_rel").val(extLinkRel);
}
- var extLinkClass = ProcessWire.config.ProcessPageEditLink.extLinkClass;
+ var extLinkClass = cfg.extLinkClass;
if (extLinkClass.length > 0) {
extLinkClass = extLinkClass.split(' ');
for(n = 0; n < extLinkClass.length; n++) {
@@ -342,10 +347,13 @@ $(document).ready(function() {
return true;
});
- $('#ProcessPageEditLinkForm').WireTabs({
- items: $(".WireTab"),
- id: 'PageEditLinkTabs'
- });
+ var $form = $('#ProcessPageEditLinkForm');
+ if($form.length) {
+ $form.WireTabs({
+ items: $(".WireTab"),
+ id: 'PageEditLinkTabs'
+ });
+ }
setTimeout(function() {
$('#link_page_url_input').focus();
diff --git a/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.min.js b/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.min.js
index ad6c6ec8..6328d592 100644
--- a/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.min.js
+++ b/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.min.js
@@ -1 +1 @@
-$(document).ready(function(){var options={selectStartLabel:ProcessWire.config.ProcessPageEditLink.selectStartLabel,selectSelectLabel:ProcessWire.config.ProcessPageEditLink.selectStartLabel,langID:ProcessWire.config.ProcessPageEditLink.langID};var options2={selectStartLabel:options.selectStartLabel,selectSelectLabel:options.selectStartLabel,langID:options.langID,rootPageID:ProcessWire.config.ProcessPageEditLink.pageID};var selectedPageData={id:0,title:"",url:""};var $fileSelect=$("#link_page_file");var $anchorSelect=$("#link_page_anchor");var $linkPageURL=$("#link_page_url_input");var $linkText=$("#link_text");$linkPageURL.val($("#link_page_url").val());function populateFileSelect(selectedPageData){var $wrap=$("#wrap_link_page_file");$.getJSON("./files?id="+selectedPageData.id,function(data){$fileSelect.empty();$fileSelect.append("");$.each(data,function(key,val){var $option=$("");$fileSelect.append($option)});$wrap.find("p.notes strong").text(selectedPageData.url);if($fileSelect.is(":visible")){$wrap.children().effect("highlight",{},500);$fileSelect.effect("bounce",{},50)}})}function absoluteToRelativePath(path){if(ProcessWire.config.ProcessPageEditLink.urlType==0)return path;function slashesToRelative(url){url=url.replace(/\//g,"../");url=url.replace(/[^.\/]/g,"");return url}var url;if(path===ProcessWire.config.ProcessPageEditLink.pageUrl){path="./";if(!ProcessWire.config.ProcessPageEditLink.slashUrls)path+=ProcessWire.config.ProcessPageEditLink.pageName}else if(path.indexOf(ProcessWire.config.ProcessPageEditLink.pageUrl)===0){path=path.substring(ProcessWire.config.ProcessPageEditLink.pageUrl.length);if(!ProcessWire.config.ProcessPageEditLink.slashUrls)path=ProcessWire.config.ProcessPageEditLink.pageName+path}else if(ProcessWire.config.ProcessPageEditLink.pageUrl.indexOf(path)===0){url=ProcessWire.config.ProcessPageEditLink.pageUrl.substring(path.length);if(url.indexOf("/")!=-1){url=slashesToRelative(url)}else{url="./"}path=url}else if(path.indexOf(ProcessWire.config.ProcessPageEditLink.rootParentUrl)===0){url=path.substring(ProcessWire.config.ProcessPageEditLink.rootParentUrl.length);var url2=url;url=slashesToRelative(url)+url2;path=url}else if(ProcessWire.config.ProcessPageEditLink.urlType==2){url=ProcessWire.config.ProcessPageEditLink.pageUrl.substring(config.urls.root.length);url=slashesToRelative(url);path=path.substring(ProcessWire.config.urls.root.length);path=url+path}return path}function pageSelected(event,data){if(data.url&&data.url.length){selectedPageData=data;selectedPageData.url=ProcessWire.config.urls.root+data.url.substring(1);selectedPageData.url=absoluteToRelativePath(selectedPageData.url);$linkPageURL.val(selectedPageData.url).change();populateFileSelect(selectedPageData)}$(this).parents(".InputfieldInteger").children(".InputfieldHeader").click().parent().find(".PageListSelectHeader").removeClass("hidden").show()}$("#link_page_id").ProcessPageList(options).hide().bind("pageSelected",pageSelected);$("#child_page_id").ProcessPageList(options2).hide().bind("pageSelected",pageSelected);$fileSelect.change(function(){var $t=$(this);var src=$t.val();if(src.length)$linkPageURL.val(src).change()});if($anchorSelect.length){var anchorPreviousValue=$anchorSelect.val();$anchorSelect.change(function(){var val=$(this).val();if(val.length){$linkPageURL.val(val);anchorPreviousValue=val}else{if($linkPageURL.val()==anchorPreviousValue)$linkPageURL.val("")}$linkPageURL.change()})}function updateLinkPreview(){if(!$linkPageURL.val().length){$("#link_markup").text("");return}var $link=$("");$link.attr("href",$linkPageURL.val());var $linkTitle=$("#link_title");if($linkTitle.length&&$linkTitle.val().length){var val=$("
").text($linkTitle.val()).html();$link.attr("title",val)}if(ProcessWire.config.ProcessPageEditLink.noLinkTextEdit){}else if($linkText.length&&$linkText.val().length){$link.text($linkText.val())}var $linkRel=$("#link_rel");if($linkRel.length&&$linkRel.val().length){$link.attr("rel",$linkRel.val())}var $linkTarget=$("#link_target");if($linkTarget.length&&$linkTarget.val().length){$link.attr("target",$linkTarget.val())}var $linkClass=$("#wrap_link_class").find("input:checked");if($linkClass.length){$linkClass.each(function(){$link.addClass($(this).val())})}$("#link_markup").text($link[0].outerHTML)}function urlKeydown(){var $this=$linkPageURL;var val=$.trim($this.val());var dotpos=val.indexOf(".");var slashespos=val.indexOf("//");var hasScheme=slashespos>-1&&slashespos-1?val.indexOf("/",slashespos+2):val.indexOf("/");var httpHost;var n;if(dotpos>-1&&val.indexOf("..")==-1&&val.indexOf("./")==-1&&(slashpos>dotpos&&!hasScheme||slashpos==-1&&dotpos>1&&val.match(/^[a-z][-a-z.0-9]+\.[a-z]{2,}($|\/)/i))){var domain=val.substring(0,slashpos>0?slashpos:val.length);hasScheme=true;if($this.attr("data-ignore")==domain){}else{$this.val("http://"+val);$this.closest(".InputfieldContent").find(".notes").text("http://"+val);$this.attr("data-ignore",domain)}}else if(dotpos>0&&val.indexOf("@")>0&&val.indexOf(":")==-1&&val.match(/^[^@]+@[-.a-z0-9]{2,}\.[a-z]{2,}$/i)){$this.val("mailto:"+val);$this.addClass("email")}else if(val.indexOf("@")==-1&&$this.hasClass("email")){$this.removeClass("email")}if(val.substring(0,1)=="#"){$this.addClass("anchor")}else if($this.hasClass("anchor")){$this.removeClass("anchor")}if(hasScheme){if(slashpos==-1)slashpos=val.length;httpHost=slashespos>-1?val.substring(slashespos+2,slashpos):val.substring(0,slashpos);$this.attr("data-httphost",httpHost)}else{$this.removeAttr("data-httphost")}function icon(){return $this.closest(".Inputfield").children(".InputfieldHeader").children("i").eq(0)}var external=false;httpHost=$this.attr("data-httphost");if(httpHost&&httpHost.length){external=true;for(n=0;n0){$("#link_target").val(extLinkTarget)}var extLinkRel=ProcessWire.config.ProcessPageEditLink.extLinkRel;if(extLinkRel.length>0){$("#link_rel").val(extLinkRel)}var extLinkClass=ProcessWire.config.ProcessPageEditLink.extLinkClass;if(extLinkClass.length>0){extLinkClass=extLinkClass.split(" ");for(n=0;n");$.each(data,function(key,val){var $option=$("");$fileSelect.append($option)});$wrap.find("p.notes strong").text(selectedPageData.url);if($fileSelect.is(":visible")){$wrap.children().effect("highlight",{},500);$fileSelect.effect("bounce",{},50)}})}function absoluteToRelativePath(path){if(cfg.urlType==0)return path;function slashesToRelative(url){url=url.replace(/\//g,"../");url=url.replace(/[^.\/]/g,"");return url}var url;if(path===cfg.pageUrl){path="./";if(!cfg.slashUrls)path+=cfg.pageName}else if(path.indexOf(cfg.pageUrl)===0){path=path.substring(cfg.pageUrl.length);if(!cfg.slashUrls)path=cfg.pageName+path}else if(cfg.pageUrl.indexOf(path)===0){url=cfg.pageUrl.substring(path.length);if(url.indexOf("/")!=-1){url=slashesToRelative(url)}else{url="./"}path=url}else if(path.indexOf(cfg.rootParentUrl)===0){url=path.substring(cfg.rootParentUrl.length);var url2=url;url=slashesToRelative(url)+url2;path=url}else if(cfg.urlType==2){url=cfg.pageUrl.substring(ProcessWire.config.urls.root.length);url=slashesToRelative(url);path=path.substring(ProcessWire.config.urls.root.length);path=url+path}return path}function pageSelected(event,data){if(data.url&&data.url.length){selectedPageData=data;selectedPageData.url=ProcessWire.config.urls.root+data.url.substring(1);selectedPageData.url=absoluteToRelativePath(selectedPageData.url);$linkPageURL.val(selectedPageData.url).change();populateFileSelect(selectedPageData)}$(this).parents(".InputfieldInteger").children(".InputfieldHeader").click().parent().find(".PageListSelectHeader").removeClass("hidden").show()}$("#link_page_id").ProcessPageList(options).hide().bind("pageSelected",pageSelected);$("#child_page_id").ProcessPageList(options2).hide().bind("pageSelected",pageSelected);$fileSelect.change(function(){var $t=$(this);var src=$t.val();if(src.length)$linkPageURL.val(src).change()});if($anchorSelect.length){var anchorPreviousValue=$anchorSelect.val();$anchorSelect.change(function(){var val=$(this).val();if(val.length){$linkPageURL.val(val);anchorPreviousValue=val}else{if($linkPageURL.val()==anchorPreviousValue)$linkPageURL.val("")}$linkPageURL.change()})}function updateLinkPreview(){if(!$linkPageURL.val().length){$("#link_markup").text("");return}var $link=$("");$link.attr("href",$linkPageURL.val());var $linkTitle=$("#link_title");if($linkTitle.length&&$linkTitle.val().length){var val=$("").text($linkTitle.val()).html();$link.attr("title",val)}if(cfg.noLinkTextEdit){}else if($linkText.length&&$linkText.val().length){$link.text($linkText.val())}var $linkRel=$("#link_rel");if($linkRel.length&&$linkRel.val().length){$link.attr("rel",$linkRel.val())}var $linkTarget=$("#link_target");if($linkTarget.length&&$linkTarget.val().length){$link.attr("target",$linkTarget.val())}var $linkClass=$("#wrap_link_class").find("input:checked");if($linkClass.length){$linkClass.each(function(){$link.addClass($(this).val())})}$("#link_markup").text($link[0].outerHTML)}function urlKeydown(){var $this=$linkPageURL;var val=$.trim($this.val());var dotpos=val.indexOf(".");var slashespos=val.indexOf("//");var hasScheme=slashespos>-1&&slashespos-1?val.indexOf("/",slashespos+2):val.indexOf("/");var httpHost;var n;if(dotpos>-1&&val.indexOf("..")==-1&&val.indexOf("./")==-1&&(slashpos>dotpos&&!hasScheme||slashpos==-1&&dotpos>1&&val.match(/^[a-z][-a-z.0-9]+\.[a-z]{2,}($|\/)/i))){var domain=val.substring(0,slashpos>0?slashpos:val.length);hasScheme=true;if($this.attr("data-ignore")==domain){}else{$this.val("http://"+val);$this.closest(".InputfieldContent").find(".notes").text("http://"+val);$this.attr("data-ignore",domain)}}else if(dotpos>0&&val.indexOf("@")>0&&val.indexOf(":")==-1&&val.match(/^[^@]+@[-.a-z0-9]{2,}\.[a-z]{2,}$/i)){$this.val("mailto:"+val);$this.addClass("email")}else if(val.indexOf("@")==-1&&$this.hasClass("email")){$this.removeClass("email")}if(val.substring(0,1)=="#"){$this.addClass("anchor")}else if($this.hasClass("anchor")){$this.removeClass("anchor")}if(hasScheme){if(slashpos==-1)slashpos=val.length;httpHost=slashespos>-1?val.substring(slashespos+2,slashpos):val.substring(0,slashpos);$this.attr("data-httphost",httpHost)}else{$this.removeAttr("data-httphost")}function icon(){return $this.closest(".Inputfield").children(".InputfieldHeader").children("i").eq(0)}var external=false;httpHost=$this.attr("data-httphost");if(httpHost&&httpHost.length){external=true;for(n=0;n0){$("#link_target").val(extLinkTarget)}var extLinkRel=cfg.extLinkRel;if(extLinkRel.length>0){$("#link_rel").val(extLinkRel)}var extLinkClass=cfg.extLinkClass;if(extLinkClass.length>0){extLinkClass=extLinkClass.split(" ");for(n=0;n 'Page Edit Link',
'summary' => 'Provides a link capability as used by some Fieldtype modules (like rich text editors).',
- 'version' => 110,
+ 'version' => 111,
'permanent' => true,
'permission' => 'page-edit',
'icon' => 'link',
@@ -72,6 +72,14 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
*/
protected $langID = 0;
+ /**
+ * Has init method been called?
+ *
+ * @var bool
+ *
+ */
+ protected $init = false;
+
/**
* Get default configuration settings
*
@@ -97,49 +105,33 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
*/
public function __construct() {
parent::__construct();
- foreach(self::getDefaultSettings() as $key => $value) {
- $this->set($key, $value);
- }
+ $this->setArray(self::getDefaultSettings());
+ }
+
+ public function init() {
+ $this->init = true;
+ parent::init();
}
/**
- * Init
- *
- * @throws WireException
+ * Set
*
+ * @param string $key
+ * @param string|int|array $value
+ * @return self
+ *
*/
- public function init() {
- $input = $this->wire()->input;
- $pages = $this->wire()->pages;
- $modules = $this->wire()->modules;
- $sanitizer = $this->wire()->sanitizer;
-
- $this->startLabel = $this->_('Choose page');
- $modules->get('ProcessPageList');
- $id = (int) $input->get('id');
- $this->langID = (int) $input->get('lang');
- if($id) $this->page = $pages->get($id);
- if($this->page && $this->page->id && !$this->wire()->user->hasPermission("page-view", $this->page)) {
- throw new WireException("You don't have access to this page");
+ public function set($key, $value) {
+ if(!$this->init) return parent::set($key, $value);
+ if($key === 'classOptions' || $key === 'relOptions' || $key === 'targetOptions') {
+ $value = $this->wire()->sanitizer->htmlClasses($value, true);
+ $value = implode("\n", $value);
+ } else if($key === 'extLinkRel' || $key === 'extLinkClass') {
+ $value = $this->wire()->sanitizer->htmlClasses($value);
+ } else if($key === 'extLinkTarget') {
+ $value = $this->wire()->sanitizer->htmlClass($value);
}
- if(!$this->page) $this->page = $pages->newNullPage();
-
- $this->wire()->config->js('ProcessPageEditLink', array(
- 'selectStartLabel' => $this->startLabel,
- 'langID' => $this->langID,
- 'pageID' => $id,
- 'pageUrl' => $this->page->url,
- 'pageName' => $this->page->name,
- 'rootParentUrl' => $this->page->rootParent->url,
- 'slashUrls' => $this->page->template ? $this->page->template->slashUrls : 1,
- 'urlType' => $this->urlType,
- 'extLinkRel' => $sanitizer->names($this->extLinkRel),
- 'extLinkTarget' => $this->extLinkTarget,
- 'extLinkClass' => $sanitizer->names($this->extLinkClass),
- 'noLinkTextEdit' => (int) $this->noLinkTextEdit
- ));
-
- parent::init();
+ return parent::set($key, $value);
}
/**
@@ -153,8 +145,34 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$sanitizer = $this->wire()->sanitizer;
$modules = $this->wire()->modules;
$config = $this->wire()->config;
+ $pages = $this->wire()->pages;
$input = $this->wire()->input;
-
+
+ $this->startLabel = $this->_('Choose page');
+ $modules->get('ProcessPageList');
+ $id = (int) $input->get('id');
+ $this->langID = (int) $input->get('lang');
+ if($id) $this->page = $pages->get($id);
+ if($this->page && $this->page->id && !$this->wire()->user->hasPermission("page-view", $this->page)) {
+ throw new WireException("You don't have access to this page");
+ }
+ if(!$this->page) $this->page = $pages->newNullPage();
+
+ $this->wire()->config->js('ProcessPageEditLink', array(
+ 'selectStartLabel' => $this->startLabel,
+ 'langID' => $this->langID,
+ 'pageID' => $id,
+ 'pageUrl' => $this->page->url,
+ 'pageName' => $this->page->name,
+ 'rootParentUrl' => $this->page->rootParent->url,
+ 'slashUrls' => $this->page->template ? $this->page->template->slashUrls : 1,
+ 'urlType' => $this->urlType,
+ 'extLinkRel' => $sanitizer->names($this->extLinkRel),
+ 'extLinkTarget' => $this->extLinkTarget,
+ 'extLinkClass' => $sanitizer->names($this->extLinkClass),
+ 'noLinkTextEdit' => (int) $this->noLinkTextEdit
+ ));
+
if($input->get('href')) {
$currentValue = $sanitizer->url($input->get('href'), array(
'stripQuotes' => false,
@@ -269,7 +287,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$field->label = $this->_('Title');
$field->description = $this->_('Additional text to describe link.');
if($input->get('title')) {
- $field->attr('value', $sanitizer->text($input->get('title')));
+ $field->attr('value', $sanitizer->unentities($sanitizer->text($input->get('title'))));
}
$fieldset->add($field);
@@ -294,15 +312,16 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$this->addSelectOptions($field, 'rel', $this->relOptions);
$fieldset->add($field);
}
-
- if($this->classOptions) {
+
+ $classOptions = $this->getClassOptions();
+ if($classOptions) {
/** @var InputfieldCheckboxes $field */
$field = $modules->get('InputfieldCheckboxes');
$field->attr('id+name', 'link_class');
$field->label = $this->_('Class');
$field->description = $this->_('Additional classes that can affect the look or behavior of the link.');
$field->optionColumns = 1;
- $this->addSelectOptions($field, 'class', $this->classOptions);
+ $this->addSelectOptions($field, 'class', $classOptions);
$fieldset->add($field);
}
@@ -315,6 +334,28 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
return $form->render() . "
";
}
+ /**
+ * Get class options string
+ *
+ * This gets class options specified with module and those specified in input.get[class].
+ *
+ * @return string Newline separated string of class options
+ * @since 3.0.212
+ *
+ */
+ protected function getClassOptions() {
+
+ $sanitizer = $this->wire()->sanitizer;
+ $class = $this->wire()->input->get->text('class');
+ if(!$class) return $this->classOptions;
+
+ $classOptions = $this->classOptions ? explode("\n", trim("$this->classOptions")) : array();
+ $classOptions = array_merge($classOptions, explode(' ', $class));
+ $classOptions = $sanitizer->htmlClasses($classOptions, true);
+
+ return count($classOptions) ? implode("\n", $classOptions) : '';
+ }
+
/**
* @param InputfieldSelect $field
* @param $attrName
@@ -459,15 +500,16 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
return $field;
}
-
- public function getModuleConfigInputfields(array $data) {
+
+ /**
+ * Module configuration
+ *
+ * @param InputfieldWrapper $inputfields
+ *
+ */
+ public function getModuleConfigInputfields(InputfieldWrapper $inputfields) {
$modules = $this->wire()->modules;
- $sanitizer = $this->wire()->sanitizer;
-
- $data = array_merge(self::getDefaultSettings(), $data);
- /** @var InputfieldWrapper $inputfields */
- $inputfields = $this->wire(new InputfieldWrapper());
/** @var InputfieldFieldset $fieldset */
$fieldset = $modules->get('InputfieldFieldset');
@@ -485,7 +527,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$f = $modules->get('InputfieldTextarea');
$f->attr('name', 'classOptions');
$f->label = 'class';
- $f->attr('value', $data['classOptions']);
+ $f->attr('value', $this->classOptions);
$f->columnWidth = 34;
$fieldset->add($f);
@@ -493,7 +535,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$f = $modules->get('InputfieldTextarea');
$f->attr('name', 'relOptions');
$f->label = 'rel';
- $f->attr('value', $data['relOptions']);
+ $f->attr('value', $this->relOptions);
$f->columnWidth = 33;
$fieldset->add($f);
@@ -501,7 +543,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$f = $modules->get('InputfieldTextarea');
$f->attr('name', 'targetOptions');
$f->label = 'target';
- $f->attr('value', $data['targetOptions']);
+ $f->attr('value', $this->targetOptions);
$f->columnWidth = 33;
$fieldset->add($f);
$inputfields->add($fieldset);
@@ -518,7 +560,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$f = $modules->get('InputfieldText');
$f->attr('name', 'extLinkClass');
$f->label = 'class';
- $f->attr('value', $sanitizer->names($data['extLinkClass']));
+ $f->attr('value', $this->extLinkClass);
$f->required = false;
$f->columnWidth = 34;
$fieldset->add($f);
@@ -529,7 +571,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$f->notes = $this->_('Example: Specifying **nofollow** would make external links default to be not followed by search engines.');
$f->label = 'rel';
$f->required = false;
- $f->attr('value', $sanitizer->names($data['extLinkRel']));
+ $f->attr('value', $this->extLinkRel);
$f->columnWidth = 33;
$fieldset->add($f);
@@ -538,7 +580,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$f->attr('name', 'extLinkTarget');
$f->label = 'target';
$f->notes = $this->_('Example: Specifying **_blank** would make external links default to open in a new window.');
- $f->attr('value', $data['extLinkTarget']);
+ $f->attr('value', $this->extLinkTarget);
$f->required = false;
$f->columnWidth = 33;
$fieldset->add($f);
@@ -551,7 +593,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$f->addOption(self::urlTypeAbsolute, $this->_('Full/absolute path from root (default)'));
$f->addOption(self::urlTypeRelativeBranch, $this->_('Relative URLs in the same branches only') . '*');
$f->addOption(self::urlTypeRelativeAll, $this->_('Relative URLs always') . '*');
- $f->attr('value', isset($data['urlType']) ? $data['urlType'] : self::urlTypeAbsolute);
+ $f->attr('value', $this->urlType ? $this->urlType : self::urlTypeAbsolute);
$f->notes = $this->_('*Currently experimental');
$f->collapsed = Inputfield::collapsedYes;
$inputfields->add($f);
@@ -561,14 +603,12 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$f->attr('name', 'noLinkTextEdit');
$f->label = $this->_('Disable link text edit feature?');
$f->description = $this->_('Disables the “Edit Link Text” feature, enabling you to support links that can contain existing markup.');
- if(empty($data['noLinkTextEdit'])) {
- $f->collapsed = Inputfield::collapsedYes;
- } else {
+ if($this->noLinkTextEdit) {
$f->attr('checked', 'checked');
+ } else {
+ $f->collapsed = Inputfield::collapsedYes;
}
$inputfields->add($f);
-
- return $inputfields;
}
}