mirror of
https://github.com/processwire/processwire.git
synced 2025-08-23 23:02:58 +02:00
Fix issue processwire/processwire-issues#658 where non-specified, non-default-language pageNumUrlPrefix settings weren't properly falling back to $config default setting
This commit is contained in:
@@ -21,7 +21,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM
|
|||||||
static public function getModuleInfo() {
|
static public function getModuleInfo() {
|
||||||
return array(
|
return array(
|
||||||
'title' => 'Languages Support - Page Names',
|
'title' => 'Languages Support - Page Names',
|
||||||
'version' => 9,
|
'version' => 10,
|
||||||
'summary' => 'Required to use multi-language page names.',
|
'summary' => 'Required to use multi-language page names.',
|
||||||
'author' => 'Ryan Cramer',
|
'author' => 'Ryan Cramer',
|
||||||
'autoload' => true,
|
'autoload' => true,
|
||||||
@@ -102,6 +102,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM
|
|||||||
$this->addHookAfter('PageFinder::getQuery', $this, 'hookPageFinderGetQuery');
|
$this->addHookAfter('PageFinder::getQuery', $this, 'hookPageFinderGetQuery');
|
||||||
|
|
||||||
// tell ProcessPageView which segments are allowed for pagination
|
// tell ProcessPageView which segments are allowed for pagination
|
||||||
|
$config = $this->wire('config');
|
||||||
$pageNumUrlPrefixes = array();
|
$pageNumUrlPrefixes = array();
|
||||||
$fields = $this->wire('fields');
|
$fields = $this->wire('fields');
|
||||||
foreach($this->wire('languages') as $language) {
|
foreach($this->wire('languages') as $language) {
|
||||||
@@ -109,7 +110,10 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM
|
|||||||
if($pageNumUrlPrefix) $pageNumUrlPrefixes[] = $pageNumUrlPrefix;
|
if($pageNumUrlPrefix) $pageNumUrlPrefixes[] = $pageNumUrlPrefix;
|
||||||
$fields->setNative("name$language");
|
$fields->setNative("name$language");
|
||||||
}
|
}
|
||||||
if(count($pageNumUrlPrefixes)) $this->wire('config')->set('pageNumUrlPrefixes', $pageNumUrlPrefixes);
|
if(count($pageNumUrlPrefixes)) {
|
||||||
|
$pageNumUrlPrefixes[] = $config->pageNumUrlPrefix; // original/fallback prefix
|
||||||
|
$config->set('pageNumUrlPrefixes', $pageNumUrlPrefixes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,7 +162,11 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM
|
|||||||
|
|
||||||
$language = $this->wire('user')->language;
|
$language = $this->wire('user')->language;
|
||||||
$prefix = $this->get("pageNumUrlPrefix$language");
|
$prefix = $this->get("pageNumUrlPrefix$language");
|
||||||
if(strlen($prefix)) $this->wire('config')->pageNumUrlPrefix = $prefix;
|
if(strlen($prefix)) {
|
||||||
|
$config = $this->wire('config');
|
||||||
|
$config->set('_pageNumUrlPrefix', $config->pageNumUrlPrefix); // origial/backup url prefix
|
||||||
|
$config->pageNumUrlPrefix = $prefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -404,6 +412,10 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM
|
|||||||
if($this->force404) {
|
if($this->force404) {
|
||||||
$this->force404 = false; // prevent another 404 on the 404 page
|
$this->force404 = false; // prevent another 404 on the 404 page
|
||||||
throw new Wire404Exception();
|
throw new Wire404Exception();
|
||||||
|
// $page = $event->wire('page');
|
||||||
|
// if(!$page || ($page->id != $event->wire('config')->http404PageID)) {
|
||||||
|
// throw new Wire404Exception();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1105,15 +1117,20 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM
|
|||||||
$module = $this->wire('modules')->get('LanguageSupportPageNames');
|
$module = $this->wire('modules')->get('LanguageSupportPageNames');
|
||||||
$module->checkModuleVersion(true);
|
$module->checkModuleVersion(true);
|
||||||
$inputfields = $this->wire(new InputfieldWrapper());
|
$inputfields = $this->wire(new InputfieldWrapper());
|
||||||
|
$config = $this->wire('config');
|
||||||
|
$defaultUrlPrefix = $config->get('_pageNumUrlPrefix|pageNumUrlPrefix');
|
||||||
|
|
||||||
foreach($this->wire('languages') as $language) {
|
foreach($this->wire('languages') as $language) {
|
||||||
$f = $this->wire('modules')->get('InputfieldName');
|
$f = $this->wire('modules')->get('InputfieldName');
|
||||||
$name = "pageNumUrlPrefix$language";
|
$name = "pageNumUrlPrefix$language";
|
||||||
if($language->isDefault() && empty($data[$name])) $data[$name] = $this->wire('config')->pageNumUrlPrefix;
|
if($language->isDefault() && empty($data[$name])) $data[$name] = $defaultUrlPrefix;
|
||||||
$f->attr('name', $name);
|
$f->attr('name', $name);
|
||||||
$f->attr('value', isset($data[$name]) ? $data[$name] : '');
|
$f->attr('value', isset($data[$name]) ? $data[$name] : '');
|
||||||
$f->label = "$language->title ($language->name) - " . $this->_('Page number prefix for pagination');
|
$f->label = "$language->title ($language->name) - " . $this->_('Page number prefix for pagination');
|
||||||
$f->description = sprintf($this->_('The page number is appended to this word in paginated URLs for this language. If omitted, "%s" will be used.'), $this->wire('config')->pageNumUrlPrefix);
|
$f->description = sprintf(
|
||||||
|
$this->_('The page number is appended to this word in paginated URLs for this language. If omitted, "%s" will be used.'),
|
||||||
|
$defaultUrlPrefix
|
||||||
|
);
|
||||||
$f->required = false;
|
$f->required = false;
|
||||||
$inputfields->add($f);
|
$inputfields->add($f);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user