1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-16 19:54:24 +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:
Ryan Cramer
2017-10-13 08:17:32 -04:00
parent 5dc690af9e
commit 00c183e70f
9 changed files with 88 additions and 65 deletions

View File

@@ -804,7 +804,7 @@ class ProcessWire extends Wire {
unset($sf, $f, $x);
// when internal is true, we are not being called by an external script
$cfg['internal'] = $realIndexFile == $realScriptFile;
$cfg['internal'] = strtolower($realIndexFile) == strtolower($realScriptFile);
} else {
// when included from another app or command line script

View File

@@ -91,7 +91,7 @@ class WireDebugInfo extends Wire {
* @return array
*
*/
protected function Page(Page $page) {
public function Page(Page $page) {
$info = array(
'instanceID' => $page->instanceID,

View File

@@ -171,7 +171,7 @@ class FieldtypeCache extends Fieldtype {
$select->label = 'Fields to cache';
$select->description = 'Select all fields that you would like to be cached.';
$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.";
foreach($this->fields as $f) {

View File

@@ -773,7 +773,8 @@ class InputfieldFile extends Inputfield implements InputfieldItemList, Inputfiel
}
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->trackChange('value');
}

View File

@@ -42,6 +42,7 @@ class InputfieldPageListSelect extends Inputfield implements InputfieldPageListS
/** @var ProcessPageList $process */
$process = $this->wire('modules')->get('ProcessPageList'); // prerequisite module
$process->setPageLabelField($this->attr('name'), $this->labelFieldName);
$process->renderReady();
}
return parent::renderReady($parent, $renderValueMode);
}

View File

@@ -64,6 +64,7 @@ class InputfieldPageListSelectMultiple extends Inputfield
/** @var ProcessPageList $process */
$process = $this->wire('modules')->get('ProcessPageList'); // prerequisite module
$process->setPageLabelField($this->attr('name'), $this->labelFieldName);
$process->renderReady();
}
return parent::renderReady($parent, $renderValueMode);
}

View File

@@ -141,6 +141,10 @@ $(document).ready(function() {
var isModal = $("body").hasClass("modal") || $("body").hasClass("pw-iframe");
if(typeof ProcessWire.config.ProcessPageList != "undefined") {
$.extend(options, ProcessWire.config.ProcessPageList);
}
$.extend(options, customOptions);
return this.each(function(index) {

File diff suppressed because one or more lines are too long

View File

@@ -212,17 +212,47 @@ class ProcessPageList extends Process implements ConfigurableModule {
protected function render() {
$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');
$config = $this->wire('config');
$session = $this->wire('session');
$urls = $config->urls;
$isAjax = $config->ajax;
$openPageIDs = array();
$openPageData = array();
$script = '';
if($this->openPage) {
if($this->openPage->id > 1) {
$openPageIDs[] = $this->openPage->id;
foreach($this->openPage->parents() as $parent) {
@@ -236,11 +266,7 @@ class ProcessPageList extends Process implements ConfigurableModule {
}
}
if($isAjax) {
if($input->get('renderInputfieldAjax')) {
$script = "<script>ProcessPageListInit();</script>";
}
} else if(count($openPageIDs)) {
if(!$isAjax && count($openPageIDs)) {
$render = $this->render;
$this->render = 'JSON';
foreach($openPageIDs as $key => $openPageID) {
@@ -259,6 +285,7 @@ class ProcessPageList extends Process implements ConfigurableModule {
}
$this->render = $render;
}
}
$defaults = array(
'containerID' => 'PageListContainer',
@@ -289,17 +316,6 @@ class ProcessPageList extends Process implements ConfigurableModule {
$settings = $config->ProcessPageList;
$settings = is_array($settings) ? array_merge($defaults, $settings) : $defaults;
$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";
}
/**