mirror of
https://github.com/processwire/processwire.git
synced 2025-08-17 20:11:46 +02:00
Some code adjustments in ProcessPageList to support a separate renderReady() method, as well as some tweaks per @EntitySelf evernote document
This commit is contained in:
@@ -804,7 +804,7 @@ class ProcessWire extends Wire {
|
|||||||
unset($sf, $f, $x);
|
unset($sf, $f, $x);
|
||||||
|
|
||||||
// when internal is true, we are not being called by an external script
|
// when internal is true, we are not being called by an external script
|
||||||
$cfg['internal'] = $realIndexFile == $realScriptFile;
|
$cfg['internal'] = strtolower($realIndexFile) == strtolower($realScriptFile);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// when included from another app or command line script
|
// when included from another app or command line script
|
||||||
|
@@ -91,7 +91,7 @@ class WireDebugInfo extends Wire {
|
|||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function Page(Page $page) {
|
public function Page(Page $page) {
|
||||||
|
|
||||||
$info = array(
|
$info = array(
|
||||||
'instanceID' => $page->instanceID,
|
'instanceID' => $page->instanceID,
|
||||||
|
@@ -171,7 +171,7 @@ class FieldtypeCache extends Fieldtype {
|
|||||||
$select->label = 'Fields to cache';
|
$select->label = 'Fields to cache';
|
||||||
$select->description = 'Select all fields that you would like to be cached.';
|
$select->description = 'Select all fields that you would like to be cached.';
|
||||||
$select->notes =
|
$select->notes =
|
||||||
"If you don't have 'autojoin' checked under this field's advanced settings, the you will have to " .
|
"If you don't have 'autojoin' checked under this field's advanced settings, then you will have to " .
|
||||||
"call \$page->{$field->name} before the cached fields will be loaded.";
|
"call \$page->{$field->name} before the cached fields will be loaded.";
|
||||||
|
|
||||||
foreach($this->fields as $f) {
|
foreach($this->fields as $f) {
|
||||||
|
@@ -773,7 +773,8 @@ class InputfieldFile extends Inputfield implements InputfieldItemList, Inputfiel
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function ___processInputDeleteFile(Pagefile $pagefile) {
|
protected function ___processInputDeleteFile(Pagefile $pagefile) {
|
||||||
$this->message($this->_("Deleted file:") . " $pagefile"); // Label that precedes a deleted filename
|
$fileLabel = $this->wire('config')->debug ? $pagefile->url() : $pagefile->name;
|
||||||
|
$this->message($this->_("Deleted file:") . " $fileLabel"); // Label that precedes a deleted filename
|
||||||
$this->value->delete($pagefile);
|
$this->value->delete($pagefile);
|
||||||
$this->trackChange('value');
|
$this->trackChange('value');
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,7 @@ class InputfieldPageListSelect extends Inputfield implements InputfieldPageListS
|
|||||||
/** @var ProcessPageList $process */
|
/** @var ProcessPageList $process */
|
||||||
$process = $this->wire('modules')->get('ProcessPageList'); // prerequisite module
|
$process = $this->wire('modules')->get('ProcessPageList'); // prerequisite module
|
||||||
$process->setPageLabelField($this->attr('name'), $this->labelFieldName);
|
$process->setPageLabelField($this->attr('name'), $this->labelFieldName);
|
||||||
|
$process->renderReady();
|
||||||
}
|
}
|
||||||
return parent::renderReady($parent, $renderValueMode);
|
return parent::renderReady($parent, $renderValueMode);
|
||||||
}
|
}
|
||||||
|
@@ -64,6 +64,7 @@ class InputfieldPageListSelectMultiple extends Inputfield
|
|||||||
/** @var ProcessPageList $process */
|
/** @var ProcessPageList $process */
|
||||||
$process = $this->wire('modules')->get('ProcessPageList'); // prerequisite module
|
$process = $this->wire('modules')->get('ProcessPageList'); // prerequisite module
|
||||||
$process->setPageLabelField($this->attr('name'), $this->labelFieldName);
|
$process->setPageLabelField($this->attr('name'), $this->labelFieldName);
|
||||||
|
$process->renderReady();
|
||||||
}
|
}
|
||||||
return parent::renderReady($parent, $renderValueMode);
|
return parent::renderReady($parent, $renderValueMode);
|
||||||
}
|
}
|
||||||
|
@@ -141,6 +141,10 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
var isModal = $("body").hasClass("modal") || $("body").hasClass("pw-iframe");
|
var isModal = $("body").hasClass("modal") || $("body").hasClass("pw-iframe");
|
||||||
|
|
||||||
|
if(typeof ProcessWire.config.ProcessPageList != "undefined") {
|
||||||
|
$.extend(options, ProcessWire.config.ProcessPageList);
|
||||||
|
}
|
||||||
|
|
||||||
$.extend(options, customOptions);
|
$.extend(options, customOptions);
|
||||||
|
|
||||||
return this.each(function(index) {
|
return this.each(function(index) {
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -212,17 +212,47 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
|||||||
protected function render() {
|
protected function render() {
|
||||||
|
|
||||||
$this->setupBreadcrumbs();
|
$this->setupBreadcrumbs();
|
||||||
if($this->render) return $this->getPageListRender($this->page)->render();
|
|
||||||
|
if($this->render) {
|
||||||
|
return $this->getPageListRender($this->page)->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
$session = $this->wire('session');
|
||||||
|
$input = $this->wire('input');
|
||||||
|
$isAjax = $this->wire('config')->ajax;
|
||||||
|
$tokenName = $session->CSRF->getTokenName();
|
||||||
|
$tokenValue = $session->CSRF->getTokenValue();
|
||||||
|
$class = $this->id ? "PageListContainerPage" : "PageListContainerRoot";
|
||||||
|
$script = '';
|
||||||
|
|
||||||
|
$this->renderReady();
|
||||||
|
|
||||||
|
if($isAjax && $input->get('renderInputfieldAjax')) {
|
||||||
|
$script = "<script>ProcessPageListInit();</script>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "\n" .
|
||||||
|
"<div id='PageListContainer' " .
|
||||||
|
"class='$class' " .
|
||||||
|
"data-token-name='$tokenName' " . // CSRF tokens
|
||||||
|
"data-token-value='$tokenValue'>" .
|
||||||
|
"</div>$script";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup for render
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function renderReady() {
|
||||||
|
|
||||||
$input = $this->wire('input');
|
$input = $this->wire('input');
|
||||||
$config = $this->wire('config');
|
$config = $this->wire('config');
|
||||||
$session = $this->wire('session');
|
|
||||||
$urls = $config->urls;
|
$urls = $config->urls;
|
||||||
$isAjax = $config->ajax;
|
$isAjax = $config->ajax;
|
||||||
$openPageIDs = array();
|
$openPageIDs = array();
|
||||||
$openPageData = array();
|
$openPageData = array();
|
||||||
$script = '';
|
|
||||||
|
|
||||||
|
if($this->openPage) {
|
||||||
if($this->openPage->id > 1) {
|
if($this->openPage->id > 1) {
|
||||||
$openPageIDs[] = $this->openPage->id;
|
$openPageIDs[] = $this->openPage->id;
|
||||||
foreach($this->openPage->parents() as $parent) {
|
foreach($this->openPage->parents() as $parent) {
|
||||||
@@ -236,11 +266,7 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($isAjax) {
|
if(!$isAjax && count($openPageIDs)) {
|
||||||
if($input->get('renderInputfieldAjax')) {
|
|
||||||
$script = "<script>ProcessPageListInit();</script>";
|
|
||||||
}
|
|
||||||
} else if(count($openPageIDs)) {
|
|
||||||
$render = $this->render;
|
$render = $this->render;
|
||||||
$this->render = 'JSON';
|
$this->render = 'JSON';
|
||||||
foreach($openPageIDs as $key => $openPageID) {
|
foreach($openPageIDs as $key => $openPageID) {
|
||||||
@@ -259,6 +285,7 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
|||||||
}
|
}
|
||||||
$this->render = $render;
|
$this->render = $render;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'containerID' => 'PageListContainer',
|
'containerID' => 'PageListContainer',
|
||||||
@@ -289,17 +316,6 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
|||||||
$settings = $config->ProcessPageList;
|
$settings = $config->ProcessPageList;
|
||||||
$settings = is_array($settings) ? array_merge($defaults, $settings) : $defaults;
|
$settings = is_array($settings) ? array_merge($defaults, $settings) : $defaults;
|
||||||
$config->js('ProcessPageList', $settings);
|
$config->js('ProcessPageList', $settings);
|
||||||
|
|
||||||
$tokenName = $session->CSRF->getTokenName();
|
|
||||||
$tokenValue = $session->CSRF->getTokenValue();
|
|
||||||
$class = $this->id ? "PageListContainerPage" : "PageListContainerRoot";
|
|
||||||
|
|
||||||
return "\n" .
|
|
||||||
"<div id='PageListContainer' " .
|
|
||||||
"class='$class' " .
|
|
||||||
"data-token-name='$tokenName' " . // CSRF tokens
|
|
||||||
"data-token-value='$tokenValue'>" .
|
|
||||||
"</div>$script";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user