mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 09:14:58 +02:00
Update ProcessPageEditLink by adding a ___buildForm() method so that one can manipulate what the "edit link" form shows by hooking that new method
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
* @property string $extLinkClass
|
* @property string $extLinkClass
|
||||||
* @property int $noLinkTextEdit 3.0.211+
|
* @property int $noLinkTextEdit 3.0.211+
|
||||||
*
|
*
|
||||||
|
* @method InputfieldForm buildForm($currentValue, $currentText)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ProcessPageEditLink extends Process implements ConfigurableModule {
|
class ProcessPageEditLink extends Process implements ConfigurableModule {
|
||||||
@@ -207,36 +209,23 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary execute
|
* Build the edit link form
|
||||||
*
|
*
|
||||||
* @return string
|
* @param string Current href value $currentValue
|
||||||
|
* @param string Current linked text $currentText
|
||||||
|
* @since 3.0.217
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function ___execute() {
|
protected function ___buildForm($currentValue, $currentText) {
|
||||||
|
|
||||||
$sanitizer = $this->wire()->sanitizer;
|
$sanitizer = $this->wire()->sanitizer;
|
||||||
$modules = $this->wire()->modules;
|
$modules = $this->wire()->modules;
|
||||||
$config = $this->wire()->config;
|
$config = $this->wire()->config;
|
||||||
$input = $this->wire()->input;
|
$input = $this->wire()->input;
|
||||||
|
|
||||||
$this->setup();
|
|
||||||
|
|
||||||
if($input->get('href')) {
|
|
||||||
$currentValue = $sanitizer->url($input->get('href'), array(
|
|
||||||
'stripQuotes' => false,
|
|
||||||
'allowIDN' => true,
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
$currentValue = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$currentText = $input->get('text');
|
|
||||||
$currentText = $currentText === null ? '' : $this->wire()->sanitizer->text($currentText);
|
|
||||||
|
|
||||||
/** @var InputfieldForm $form */
|
/** @var InputfieldForm $form */
|
||||||
$form = $modules->get("InputfieldForm");
|
$form = $modules->get("InputfieldForm");
|
||||||
$form->attr('id', 'ProcessPageEditLinkForm');
|
$form->attr('id', 'ProcessPageEditLinkForm');
|
||||||
//$form->description = $this->_("Enter a URL, select a page, or select a file to link:"); // Headline
|
|
||||||
|
|
||||||
$modules->get('JqueryWireTabs');
|
$modules->get('JqueryWireTabs');
|
||||||
|
|
||||||
@@ -389,7 +378,37 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
|
|||||||
sprintf(
|
sprintf(
|
||||||
$this->_('You may customize available attributes shown above in the %s module settings.'),
|
$this->_('You may customize available attributes shown above in the %s module settings.'),
|
||||||
"[ProcessPageEditLink](" . $config->urls->admin . "module/edit?name=ProcessPageEditLink)"
|
"[ProcessPageEditLink](" . $config->urls->admin . "module/edit?name=ProcessPageEditLink)"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary execute
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function ___execute() {
|
||||||
|
|
||||||
|
$sanitizer = $this->wire()->sanitizer;
|
||||||
|
$input = $this->wire()->input;
|
||||||
|
|
||||||
|
$this->setup();
|
||||||
|
|
||||||
|
if($input->get('href')) {
|
||||||
|
$currentValue = $sanitizer->url($input->get('href'), array(
|
||||||
|
'stripQuotes' => false,
|
||||||
|
'allowIDN' => true,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$currentValue = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentText = $input->get('text');
|
||||||
|
$currentText = $currentText === null ? '' : $this->wire()->sanitizer->text($currentText);
|
||||||
|
|
||||||
|
$form = $this->buildForm($currentValue, $currentText);
|
||||||
|
|
||||||
return $form->render() . "<p class='detail ui-priority-secondary'><code id='link_markup'></code></p>";
|
return $form->render() . "<p class='detail ui-priority-secondary'><code id='link_markup'></code></p>";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user