mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 17:54:44 +02:00
Various minor tweaks and documentation improvements
This commit is contained in:
@@ -26,6 +26,8 @@ if(!defined("PROCESSWIRE")) die();
|
|||||||
|
|
||||||
/*** SITE CONFIG *************************************************************************/
|
/*** SITE CONFIG *************************************************************************/
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable debug mode?
|
* Enable debug mode?
|
||||||
*
|
*
|
||||||
|
@@ -26,6 +26,8 @@ if(!defined("PROCESSWIRE")) die();
|
|||||||
|
|
||||||
/*** SITE CONFIG *************************************************************************/
|
/*** SITE CONFIG *************************************************************************/
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable debug mode?
|
* Enable debug mode?
|
||||||
*
|
*
|
||||||
|
@@ -26,6 +26,8 @@ if(!defined("PROCESSWIRE")) die();
|
|||||||
|
|
||||||
/*** SITE CONFIG *************************************************************************/
|
/*** SITE CONFIG *************************************************************************/
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable debug mode?
|
* Enable debug mode?
|
||||||
*
|
*
|
||||||
|
@@ -26,6 +26,8 @@ if(!defined("PROCESSWIRE")) die();
|
|||||||
|
|
||||||
/*** SITE CONFIG *************************************************************************/
|
/*** SITE CONFIG *************************************************************************/
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable debug mode?
|
* Enable debug mode?
|
||||||
*
|
*
|
||||||
|
@@ -26,6 +26,8 @@ if(!defined("PROCESSWIRE")) die();
|
|||||||
|
|
||||||
/*** SITE CONFIG *************************************************************************/
|
/*** SITE CONFIG *************************************************************************/
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable debug mode?
|
* Enable debug mode?
|
||||||
*
|
*
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
*
|
*
|
||||||
* @method void install()
|
* @method void install()
|
||||||
* @method void uninstall()
|
* @method void uninstall()
|
||||||
|
* @method array getExtraMarkup()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
* @property string $httpHost Current HTTP host name. #pw-group-HTTP-and-input
|
* @property string $httpHost Current HTTP host name. #pw-group-HTTP-and-input
|
||||||
* @property bool $https If the current request is an HTTPS request, this is set to true. #pw-group-runtime
|
* @property bool $https If the current request is an HTTPS request, this is set to true. #pw-group-runtime
|
||||||
* @property string $version Current ProcessWire version string (i.e. "2.2.3") #pw-group-system #pw-group-runtime
|
* @property string $version Current ProcessWire version string (i.e. "2.2.3") #pw-group-system #pw-group-runtime
|
||||||
|
* @property int $systemVersion System version, used by SystemUpdater to determine when updates must be applied. #pw-group-system #pw-group-runtime
|
||||||
*
|
*
|
||||||
* @property FilenameArray $styles Array used by ProcessWire admin to keep track of what stylesheet files its template should load. It will be blank otherwise. Feel free to use it for the same purpose in your own sites. #pw-group-runtime
|
* @property FilenameArray $styles Array used by ProcessWire admin to keep track of what stylesheet files its template should load. It will be blank otherwise. Feel free to use it for the same purpose in your own sites. #pw-group-runtime
|
||||||
* @property FilenameArray $scripts Array used by ProcessWire admin to keep track of what javascript files its template should load. It will be blank otherwise. Feel free to use it for the same purpose in your own sites. #pw-group-runtime
|
* @property FilenameArray $scripts Array used by ProcessWire admin to keep track of what javascript files its template should load. It will be blank otherwise. Feel free to use it for the same purpose in your own sites. #pw-group-runtime
|
||||||
|
@@ -378,6 +378,19 @@ function paths($key = '') {
|
|||||||
return wirePaths($key);
|
return wirePaths($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start or stop a profiler event or return WireProfilerInterface instance
|
||||||
|
*
|
||||||
|
* @param string|array|object|null $name Name of event to start or event to stop
|
||||||
|
* @param null|object|string $source If starting an event, optional source of event (object)
|
||||||
|
* @param array $data Optional extra data as associative array
|
||||||
|
* @return null|array|object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function profiler($name = null, $source = null, $data = array()) {
|
||||||
|
return wireProfiler($name, $source, $data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or set a region for front-end output
|
* Get or set a region for front-end output
|
||||||
*
|
*
|
||||||
|
@@ -460,6 +460,26 @@ function wireLog($logName = '', $message = '') {
|
|||||||
return $log;
|
return $log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start or stop a profiler event or return WireProfilerInterface instance
|
||||||
|
*
|
||||||
|
* @param string|array|object|null $name Name of event to start or event to stop
|
||||||
|
* @param null|object|string $source If starting an event, optional source of event (object)
|
||||||
|
* @param array $data Optional extra data as associative array
|
||||||
|
* @return null|array|object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function wireProfiler($name = null, $source = null, $data = array()) {
|
||||||
|
$profiler = wire('profiler');
|
||||||
|
if(is_null($name)) return $profiler;
|
||||||
|
if(!$profiler) return null;
|
||||||
|
if(is_string($name)) {
|
||||||
|
return $profiler->start($name, $source, $data);
|
||||||
|
} else {
|
||||||
|
return $profiler->stop($name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that returns a $config->urls->[name] value o
|
* Function that returns a $config->urls->[name] value o
|
||||||
*
|
*
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
*
|
*
|
||||||
* @property-read Wire|WireData|WireArray|Module $object Instance of the object where the Hook event originated.
|
* @property-read Wire|WireData|WireArray|Module $object Instance of the object where the Hook event originated.
|
||||||
* @property-read string $method The name of the method that was called to generate the Hook event.
|
* @property-read string $method The name of the method that was called to generate the Hook event.
|
||||||
* @property-read array $arguments A numerically indexed array of the arguments sent to the above mentioned method.
|
* @property array $arguments A numerically indexed array of the arguments sent to the above mentioned method.
|
||||||
* @property mixed $return Applicable only for 'after' or ('replace' + 'before' hooks), contains the value returned by the above mentioned method. The hook handling method may modify this return value.
|
* @property mixed $return Applicable only for 'after' or ('replace' + 'before' hooks), contains the value returned by the above mentioned method. The hook handling method may modify this return value.
|
||||||
* @property bool $replace Set to boolean true in a 'before' hook if you want to prevent execution of the original hooked function. In such a case, your hook is replacing the function entirely. Not recommended, so be careful with this.
|
* @property bool $replace Set to boolean true in a 'before' hook if you want to prevent execution of the original hooked function. In such a case, your hook is replacing the function entirely. Not recommended, so be careful with this.
|
||||||
* @property array $options An optional array of user-specified data that gets sent to the hooked function. The hook handling method may access it from $event->data. Also includes all the default hook properties.
|
* @property array $options An optional array of user-specified data that gets sent to the hooked function. The hook handling method may access it from $event->data. Also includes all the default hook properties.
|
||||||
|
@@ -110,6 +110,7 @@ class AdminThemeDefaultHelpers extends WireData {
|
|||||||
if($page->name != 'page' || $this->wire('input')->urlSegment1) return '';
|
if($page->name != 'page' || $this->wire('input')->urlSegment1) return '';
|
||||||
$user = $this->wire('user');
|
$user = $this->wire('user');
|
||||||
if($this->wire('user')->isGuest() || !$user->hasPermission('page-edit')) return '';
|
if($this->wire('user')->isGuest() || !$user->hasPermission('page-edit')) return '';
|
||||||
|
/** @var ProcessPageAdd $module */
|
||||||
$module = $this->wire('modules')->getModule('ProcessPageAdd', array('noInit' => true));
|
$module = $this->wire('modules')->getModule('ProcessPageAdd', array('noInit' => true));
|
||||||
$data = $module->executeNavJSON(array('getArray' => true));
|
$data = $module->executeNavJSON(array('getArray' => true));
|
||||||
$items = array();
|
$items = array();
|
||||||
@@ -143,7 +144,7 @@ class AdminThemeDefaultHelpers extends WireData {
|
|||||||
|
|
||||||
if($this->wire('user')->isLoggedin() && $this->wire('modules')->isInstalled('SystemNotifications')) {
|
if($this->wire('user')->isLoggedin() && $this->wire('modules')->isInstalled('SystemNotifications')) {
|
||||||
$systemNotifications = $this->wire('modules')->get('SystemNotifications');
|
$systemNotifications = $this->wire('modules')->get('SystemNotifications');
|
||||||
if(!$systemNotifications->placement) return;
|
if(!$systemNotifications->placement) return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
@@ -232,7 +233,9 @@ class AdminThemeDefaultHelpers extends WireData {
|
|||||||
$info = $this->wire('modules')->getModuleInfo($p->process);
|
$info = $this->wire('modules')->getModuleInfo($p->process);
|
||||||
if(!empty($info['icon'])) $icon = $info['icon'];
|
if(!empty($info['icon'])) $icon = $info['icon'];
|
||||||
}
|
}
|
||||||
if($p->page_icon) $icon = $p->page_icon; // allow for option of an admin field overriding the module icon
|
// allow for option of an admin field overriding the module icon
|
||||||
|
$pageIcon = $p->get('page_icon');
|
||||||
|
if($pageIcon) $icon = $pageIcon;
|
||||||
if(!$icon) switch($p->id) {
|
if(!$icon) switch($p->id) {
|
||||||
case 22: $icon = 'gears'; break; // Setup
|
case 22: $icon = 'gears'; break; // Setup
|
||||||
case 21: $icon = 'plug'; break; // Modules
|
case 21: $icon = 'plug'; break; // Modules
|
||||||
@@ -360,6 +363,7 @@ class AdminThemeDefaultHelpers extends WireData {
|
|||||||
// ProcessPageAdd: avoid showing this menu item if there are no predefined family settings to use
|
// ProcessPageAdd: avoid showing this menu item if there are no predefined family settings to use
|
||||||
$numAddable = $this->wire('session')->getFor('ProcessPageAdd', 'numAddable');
|
$numAddable = $this->wire('session')->getFor('ProcessPageAdd', 'numAddable');
|
||||||
if($numAddable === null) {
|
if($numAddable === null) {
|
||||||
|
/** @var ProcessPageAdd $processPageAdd */
|
||||||
$processPageAdd = $this->wire('modules')->getModule('ProcessPageAdd', array('noInit' => true));
|
$processPageAdd = $this->wire('modules')->getModule('ProcessPageAdd', array('noInit' => true));
|
||||||
if($processPageAdd) {
|
if($processPageAdd) {
|
||||||
$addData = $processPageAdd->executeNavJSON(array("getArray" => true));
|
$addData = $processPageAdd->executeNavJSON(array("getArray" => true));
|
||||||
@@ -530,8 +534,10 @@ class AdminThemeDefaultHelpers extends WireData {
|
|||||||
*/
|
*/
|
||||||
public function renderJSConfig() {
|
public function renderJSConfig() {
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
$config = $this->wire('config');
|
$config = $this->wire('config');
|
||||||
|
|
||||||
|
/** @var array $jsConfig */
|
||||||
$jsConfig = $config->js();
|
$jsConfig = $config->js();
|
||||||
$jsConfig['debug'] = $config->debug;
|
$jsConfig['debug'] = $config->debug;
|
||||||
|
|
||||||
|
@@ -10,12 +10,26 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
|
/** @var AdminThemeDefault $adminTheme */
|
||||||
|
/** @var User $user */
|
||||||
|
/** @var Modules $modules */
|
||||||
|
/** @var Notices $notices */
|
||||||
|
/** @var Page $page */
|
||||||
|
|
||||||
if(!defined("PROCESSWIRE")) die();
|
if(!defined("PROCESSWIRE")) die();
|
||||||
|
|
||||||
if(!isset($content)) $content = '';
|
if(!isset($content)) $content = '';
|
||||||
|
|
||||||
$searchForm = $user->hasPermission('page-edit') ? $modules->get('ProcessPageSearch')->renderSearchForm() : '';
|
if($user->hasPermission('page-edit')) {
|
||||||
$version = $adminTheme->version . 'h';
|
/** @var ProcessPageSearch $searchForm */
|
||||||
|
$searchForm = $modules->get('ProcessPageSearch');
|
||||||
|
$searchForm = $searchForm->renderSearchForm();
|
||||||
|
} else {
|
||||||
|
$searchForm = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $adminTheme->version . 'i';
|
||||||
|
|
||||||
$config->styles->prepend($config->urls->root . "wire/templates-admin/styles/AdminTheme.css?v=$version");
|
$config->styles->prepend($config->urls->root . "wire/templates-admin/styles/AdminTheme.css?v=$version");
|
||||||
$config->styles->prepend($config->urls->adminTemplates . "styles/" . ($adminTheme->colors ? "main-$adminTheme->colors" : "main-classic") . ".css?v=$version");
|
$config->styles->prepend($config->urls->adminTemplates . "styles/" . ($adminTheme->colors ? "main-$adminTheme->colors" : "main-classic") . ".css?v=$version");
|
||||||
@@ -27,6 +41,7 @@ $config->scripts->append($config->urls->root . "wire/templates-admin/scripts/mai
|
|||||||
$config->scripts->append($config->urls->adminTemplates . "scripts/main.$ext?v=$version");
|
$config->scripts->append($config->urls->adminTemplates . "scripts/main.$ext?v=$version");
|
||||||
|
|
||||||
require_once(dirname(__FILE__) . "/AdminThemeDefaultHelpers.php");
|
require_once(dirname(__FILE__) . "/AdminThemeDefaultHelpers.php");
|
||||||
|
/** @var AdminThemeDefaultHelpers $helpers */
|
||||||
$helpers = $this->wire(new AdminThemeDefaultHelpers());
|
$helpers = $this->wire(new AdminThemeDefaultHelpers());
|
||||||
$extras = $adminTheme->getExtraMarkup();
|
$extras = $adminTheme->getExtraMarkup();
|
||||||
|
|
||||||
@@ -94,7 +109,9 @@ $extras = $adminTheme->getExtraMarkup();
|
|||||||
<div class="pw-container container">
|
<div class="pw-container container">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if($page->body) echo $page->body;
|
$body = $page->get('body');
|
||||||
|
if($body) echo $body;
|
||||||
|
unset($body);
|
||||||
echo $content;
|
echo $content;
|
||||||
echo $extras['content'];
|
echo $extras['content'];
|
||||||
?>
|
?>
|
||||||
@@ -120,7 +137,9 @@ $extras = $adminTheme->getExtraMarkup();
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
echo $extras['footer'];
|
echo $extras['footer'];
|
||||||
if($config->debug && $user->isSuperuser()) include($config->paths->root . '/wire/templates-admin/debug.inc');
|
if($config->debug && $user->isSuperuser()) {
|
||||||
|
include($config->paths->root . '/wire/templates-admin/debug.inc');
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div><!--/#footer-->
|
</div><!--/#footer-->
|
||||||
|
@@ -7,12 +7,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
|
/** @var ProcessWire $wire */
|
||||||
|
|
||||||
$config->inputfieldColumnWidthSpacing = 0; // percent spacing between columns
|
$config->inputfieldColumnWidthSpacing = 0; // percent spacing between columns
|
||||||
|
|
||||||
$markup = InputfieldWrapper::getMarkup();
|
$markup = InputfieldWrapper::getMarkup();
|
||||||
$markup['item_label'] = "\n\t\t<label class='InputfieldHeader' for='{for}'>{out}</label>";
|
$markup['item_label'] = "<label class='InputfieldHeader' for='{for}'>{out}</label>";
|
||||||
$markup['item_label_hidden'] = "\n\t\t<label class='InputfieldHeader InputfieldHeaderHidden'><span>{out}</span></label>";
|
$markup['item_label_hidden'] = "<label class='InputfieldHeader InputfieldHeaderHidden'><span>{out}</span></label>";
|
||||||
$markup['item_content'] = "\n\t\t<div class='InputfieldContent'>\n{out}\n\t\t</div>";
|
$markup['item_content'] = "<div class='InputfieldContent'>{out}</div>";
|
||||||
InputfieldWrapper::setMarkup($markup);
|
InputfieldWrapper::setMarkup($markup);
|
||||||
|
|
||||||
$classes = InputfieldWrapper::getClasses();
|
$classes = InputfieldWrapper::getClasses();
|
||||||
@@ -20,11 +23,13 @@ $classes['item'] = "Inputfield {class} Inputfield_{name}";
|
|||||||
$classes['item_error'] = "InputfieldStateError";
|
$classes['item_error'] = "InputfieldStateError";
|
||||||
InputfieldWrapper::setClasses($classes);
|
InputfieldWrapper::setClasses($classes);
|
||||||
|
|
||||||
wire()->addHookBefore('MarkupPagerNav::render', null, 'hookMarkupPagerNavRender');
|
$wire->addHookBefore('MarkupPagerNav::render', null, 'hookMarkupPagerNavRender');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the default prev/next links for MarkupPagerNav
|
* Change the default prev/next links for MarkupPagerNav
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
function hookMarkupPagerNavRender(HookEvent $event) {
|
function hookMarkupPagerNavRender(HookEvent $event) {
|
||||||
$options = $event->arguments(1);
|
$options = $event->arguments(1);
|
||||||
|
@@ -12,10 +12,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @var Config $config */
|
||||||
|
/** @var AdminThemeReno $adminTheme */
|
||||||
|
/** @var User $user */
|
||||||
|
/** @var Modules $modules */
|
||||||
|
|
||||||
if(!defined("PROCESSWIRE")) die();
|
if(!defined("PROCESSWIRE")) die();
|
||||||
|
|
||||||
if(!isset($content)) $content = '';
|
if(!isset($content)) $content = '';
|
||||||
$version = $adminTheme->version . 'j';
|
$version = $adminTheme->version . 'k';
|
||||||
$ext = $config->debug ? "js" : "min.js";
|
$ext = $config->debug ? "js" : "min.js";
|
||||||
|
|
||||||
// Search form
|
// Search form
|
||||||
|
@@ -175,7 +175,7 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
|
|
||||||
// identify the current language from the user, or set one if it's not already
|
// identify the current language from the user, or set one if it's not already
|
||||||
if($this->user->language && $this->user->language->id) {
|
if($this->user->language && $this->user->language->id) {
|
||||||
$language = $this->user->language;
|
// $language = $this->user->language;
|
||||||
} else {
|
} else {
|
||||||
$language = $this->defaultLanguagePage;
|
$language = $this->defaultLanguagePage;
|
||||||
$this->user->language = $language;
|
$this->user->language = $language;
|
||||||
@@ -222,7 +222,7 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
public function ready() {
|
public function ready() {
|
||||||
// styles used by our Inputfield hooks
|
// styles used by our Inputfield hooks
|
||||||
if($this->wire('page')->template == 'admin') {
|
if($this->wire('page')->template == 'admin') {
|
||||||
$this->config->styles->add($this->config->urls->LanguageSupport . "LanguageSupport.css");
|
$this->config->styles->add($this->config->urls('LanguageSupport') . "LanguageSupport.css");
|
||||||
$language = $this->wire('user')->language;
|
$language = $this->wire('user')->language;
|
||||||
if($language) $this->config->js('LanguageSupport', array(
|
if($language) $this->config->js('LanguageSupport', array(
|
||||||
'language' => array(
|
'language' => array(
|
||||||
@@ -307,6 +307,8 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
*
|
*
|
||||||
* Only applies to Inputfields that have: useLanguages == true
|
* Only applies to Inputfields that have: useLanguages == true
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookInputfieldBeforeRender(HookEvent $event) {
|
public function hookInputfieldBeforeRender(HookEvent $event) {
|
||||||
|
|
||||||
@@ -331,6 +333,8 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
* Only applies to Inputfields that have: useLanguages == false.
|
* Only applies to Inputfields that have: useLanguages == false.
|
||||||
* Applies only if page-edit-lang-none permission is installed.
|
* Applies only if page-edit-lang-none permission is installed.
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookInputfieldWrapperBeforeRenderInputfield(HookEvent $event) {
|
public function hookInputfieldWrapperBeforeRenderInputfield(HookEvent $event) {
|
||||||
|
|
||||||
@@ -372,9 +376,9 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
$out;
|
$out;
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = "\n<div class='$class' id='langTab_$id' data-language='$language->id'>" .
|
$out = "<div class='$class' id='langTab_$id' data-language='$language->id'>" .
|
||||||
"\n<label for='$id' class='$labelClass'>$label</label>" . $out .
|
"<label for='$id' class='$labelClass'>$label</label>" . $out .
|
||||||
"\n</div>";
|
"</div>";
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,6 +387,8 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
*
|
*
|
||||||
* Only applies to Inputfields that have: useLanguages == true
|
* Only applies to Inputfields that have: useLanguages == true
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookInputfieldAfterRender(HookEvent $event) {
|
public function hookInputfieldAfterRender(HookEvent $event) {
|
||||||
|
|
||||||
@@ -469,6 +475,8 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
/**
|
/**
|
||||||
* Hook before Inputfield::processInput to process input for other languages (or prevent it)
|
* Hook before Inputfield::processInput to process input for other languages (or prevent it)
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookInputfieldBeforeProcessInput(HookEvent $event) {
|
public function hookInputfieldBeforeProcessInput(HookEvent $event) {
|
||||||
|
|
||||||
@@ -503,6 +511,8 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
*
|
*
|
||||||
* Only applies to Inputfields that have: useLanguages == true
|
* Only applies to Inputfields that have: useLanguages == true
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookInputfieldAfterProcessInput(HookEvent $event) {
|
public function hookInputfieldAfterProcessInput(HookEvent $event) {
|
||||||
|
|
||||||
@@ -556,6 +566,8 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
/**
|
/**
|
||||||
* Hook into Field::getInputfield to change label/description to proper language
|
* Hook into Field::getInputfield to change label/description to proper language
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookFieldGetInputfield(HookEvent $event) {
|
public function hookFieldGetInputfield(HookEvent $event) {
|
||||||
|
|
||||||
@@ -564,7 +576,9 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
|
|
||||||
/** @var Field $field */
|
/** @var Field $field */
|
||||||
$field = $event->object;
|
$field = $event->object;
|
||||||
|
/** @var Page $page */
|
||||||
$page = $event->arguments[0];
|
$page = $event->arguments[0];
|
||||||
|
/** @var Template $template */
|
||||||
$template = $page ? $page->template : null;
|
$template = $page ? $page->template : null;
|
||||||
$inputfield = $event->return;
|
$inputfield = $event->return;
|
||||||
if(!$inputfield) return;
|
if(!$inputfield) return;
|
||||||
@@ -608,6 +622,8 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
/**
|
/**
|
||||||
* Hook called when new language added
|
* Hook called when new language added
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookPageAdded(HookEvent $event) {
|
public function hookPageAdded(HookEvent $event) {
|
||||||
|
|
||||||
@@ -631,6 +647,8 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
/**
|
/**
|
||||||
* Hook called when language is deleted
|
* Hook called when language is deleted
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookPageDeleteReady(HookEvent $event) {
|
public function hookPageDeleteReady(HookEvent $event) {
|
||||||
|
|
||||||
@@ -685,6 +703,9 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
* because it deals with both language fields and page names, and potentially
|
* because it deals with both language fields and page names, and potentially
|
||||||
* other types of unknown types that implement LanguagesValueInterface.
|
* other types of unknown types that implement LanguagesValueInterface.
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
* @throws WireException
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookPageSetLanguageValue(HookEvent $event) {
|
public function hookPageSetLanguageValue(HookEvent $event) {
|
||||||
|
|
||||||
@@ -748,11 +769,17 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
* because it deals with both language fields and page names, and potentially
|
* because it deals with both language fields and page names, and potentially
|
||||||
* other types of unknown types that implement LanguagesValueInterface.
|
* other types of unknown types that implement LanguagesValueInterface.
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
* @throws WireException
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookPageGetLanguageValue(HookEvent $event) {
|
public function hookPageGetLanguageValue(HookEvent $event) {
|
||||||
|
|
||||||
|
/** @var Page $page */
|
||||||
$page = $event->object;
|
$page = $event->object;
|
||||||
|
/** @var Language $language */
|
||||||
$language = $event->arguments(0);
|
$language = $event->arguments(0);
|
||||||
|
/** @var Field $field */
|
||||||
$field = $event->arguments(1);
|
$field = $event->arguments(1);
|
||||||
$value = null;
|
$value = null;
|
||||||
|
|
||||||
@@ -795,8 +822,12 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
/**
|
/**
|
||||||
* Module configuration screen
|
* Module configuration screen
|
||||||
*
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return InputfieldWrapper
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public static function getModuleConfigInputfields(array $data) {
|
public static function getModuleConfigInputfields(array $data) {
|
||||||
|
if($data) {}
|
||||||
$form = new InputfieldWrapper();
|
$form = new InputfieldWrapper();
|
||||||
// TBA
|
// TBA
|
||||||
return $form;
|
return $form;
|
||||||
@@ -828,9 +859,12 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
|
|||||||
/**
|
/**
|
||||||
* Install or uninstall by loading the LanguageSupportInstall script
|
* Install or uninstall by loading the LanguageSupportInstall script
|
||||||
*
|
*
|
||||||
|
* @param bool $install
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
protected function installer($install = true) {
|
protected function installer($install = true) {
|
||||||
require_once($this->config->paths->LanguageSupport . 'LanguageSupportInstall.php');
|
require_once(dirname(__FILE__) . '/LanguageSupportInstall.php');
|
||||||
|
/** @var LanguageSupportInstall $installer */
|
||||||
$installer = $this->wire(new LanguageSupportInstall());
|
$installer = $this->wire(new LanguageSupportInstall());
|
||||||
if($install) $installer->install();
|
if($install) $installer->install();
|
||||||
else $installer->uninstall();
|
else $installer->uninstall();
|
||||||
|
@@ -6,6 +6,11 @@
|
|||||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
|
* @method void languageAdded(Page $language) #pw-hooker
|
||||||
|
* @method void languageDeleted(Page $language) #pw-hooker
|
||||||
|
* @method void fieldLanguageAdded(Field $field, Page $language) #pw-hooker
|
||||||
|
* @method void fieldLanguageRemoved(Field $field, Page $language) #pw-hooker
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class LanguageSupportFields extends WireData implements Module {
|
class LanguageSupportFields extends WireData implements Module {
|
||||||
@@ -119,6 +124,8 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
* Replace a value of one field with the value from another field that has the same name, but with the language name appended to it.
|
* Replace a value of one field with the value from another field that has the same name, but with the language name appended to it.
|
||||||
* Example: title and title_es
|
* Example: title and title_es
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookFieldtypeFormatValue(HookEvent $event) {
|
public function hookFieldtypeFormatValue(HookEvent $event) {
|
||||||
|
|
||||||
@@ -131,6 +138,7 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
// exit quickly if we can determine now we don't need to continue
|
// exit quickly if we can determine now we don't need to continue
|
||||||
if(!isset($this->multilangAlternateFields[$field->name])) return;
|
if(!isset($this->multilangAlternateFields[$field->name])) return;
|
||||||
|
|
||||||
|
/** @var Page $page */
|
||||||
$page = $event->arguments[0];
|
$page = $event->arguments[0];
|
||||||
|
|
||||||
// determine name of language field, if present.
|
// determine name of language field, if present.
|
||||||
@@ -161,6 +169,8 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Hook called when new language added
|
* Hook called when new language added
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function hookLanguageAdded(HookEvent $event) {
|
public function hookLanguageAdded(HookEvent $event) {
|
||||||
|
|
||||||
@@ -179,13 +189,17 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Hookable function called when a new language is added
|
* Hookable function called when a new language is added
|
||||||
*
|
*
|
||||||
|
* @param Page|Language $language
|
||||||
|
e*
|
||||||
*/
|
*/
|
||||||
public function ___languageAdded(Page $language) {
|
public function ___languageAdded(Page $language) {
|
||||||
// hookable, intentionally blank
|
// hookable, intentionally blank
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook called when language is deleted
|
* Hook called when languag is deleted
|
||||||
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function hookLanguageDeleted(HookEvent $event) {
|
public function hookLanguageDeleted(HookEvent $event) {
|
||||||
@@ -204,6 +218,8 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Hookable function called when a language is deleted
|
* Hookable function called when a language is deleted
|
||||||
*
|
*
|
||||||
|
* @param Page|Language $language
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function ___languageDeleted(Page $language) {
|
public function ___languageDeleted(Page $language) {
|
||||||
// hookable, intentionally blank
|
// hookable, intentionally blank
|
||||||
@@ -213,6 +229,9 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Called when a new language is added to the system for each field that implements FieldtypeLanguageInterface
|
* Called when a new language is added to the system for each field that implements FieldtypeLanguageInterface
|
||||||
*
|
*
|
||||||
|
* @param Field $field
|
||||||
|
* @param Page|Language $language
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function ___fieldLanguageAdded(Field $field, Page $language) {
|
public function ___fieldLanguageAdded(Field $field, Page $language) {
|
||||||
|
|
||||||
@@ -249,6 +268,9 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Called when a language is removed from the system for each field that implements FieldtypeLanguageInterface
|
* Called when a language is removed from the system for each field that implements FieldtypeLanguageInterface
|
||||||
*
|
*
|
||||||
|
* @param Field $field
|
||||||
|
* @param Page|Language $language
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
protected function ___fieldLanguageRemoved(Field $field, Page $language) {
|
protected function ___fieldLanguageRemoved(Field $field, Page $language) {
|
||||||
|
|
||||||
@@ -277,6 +299,8 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* We may make this behavior configurable later on, as one may want to limit the search to 1 language only.
|
* We may make this behavior configurable later on, as one may want to limit the search to 1 language only.
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function pageFinderGetQuery(HookEvent $event) {
|
public function pageFinderGetQuery(HookEvent $event) {
|
||||||
|
|
||||||
@@ -289,7 +313,7 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
$arguments = $event->arguments;
|
$arguments = $event->arguments;
|
||||||
$selectors = $arguments[0];
|
$selectors = $arguments[0];
|
||||||
|
|
||||||
foreach($selectors as $key => $selector) {
|
foreach($selectors as $selector) {
|
||||||
|
|
||||||
$changed = false;
|
$changed = false;
|
||||||
$fields = $selector->field;
|
$fields = $selector->field;
|
||||||
@@ -335,6 +359,8 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* Converts the value to a LanguagesPageFieldValue
|
* Converts the value to a LanguagesPageFieldValue
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function fieldtypeLoadPageField(HookEvent $event) {
|
public function fieldtypeLoadPageField(HookEvent $event) {
|
||||||
$page = $event->arguments[0];
|
$page = $event->arguments[0];
|
||||||
@@ -350,6 +376,8 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* Converts the value to a LanguagesPageFieldValue
|
* Converts the value to a LanguagesPageFieldValue
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function fieldtypeWakeupValue(HookEvent $event) {
|
public function fieldtypeWakeupValue(HookEvent $event) {
|
||||||
|
|
||||||
@@ -375,11 +403,13 @@ class LanguageSupportFields extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* Converts a LanguagesPageFieldValue to an array
|
* Converts a LanguagesPageFieldValue to an array
|
||||||
*
|
*
|
||||||
|
* @param HookEvent $event
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function fieldtypeSleepValue(HookEvent $event) {
|
public function fieldtypeSleepValue(HookEvent $event) {
|
||||||
|
|
||||||
$page = $event->arguments[0];
|
// $page = $event->arguments[0];
|
||||||
$field = $event->arguments[1];
|
// $field = $event->arguments[1];
|
||||||
$value = $event->arguments[2];
|
$value = $event->arguments[2];
|
||||||
//$value = $event->return;
|
//$value = $event->return;
|
||||||
$values = array();
|
$values = array();
|
||||||
|
@@ -9,6 +9,9 @@
|
|||||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
|
* @method void install()
|
||||||
|
* @method void uninstall()
|
||||||
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ class LanguageTabs extends WireData implements Module, ConfigurableModule {
|
|||||||
// so if you want to focus on the Spanish tabs when the user clicks "edit"
|
// so if you want to focus on the Spanish tabs when the user clicks "edit"
|
||||||
// from /es/path/to/page/, then you can by using a page edit link like:
|
// from /es/path/to/page/, then you can by using a page edit link like:
|
||||||
// <a href='{$config->urls->admin}page/edit/?id=$page->id&language=$user->language'>Edit</a>
|
// <a href='{$config->urls->admin}page/edit/?id=$page->id&language=$user->language'>Edit</a>
|
||||||
$id = (int) $this->input->get->language;
|
$id = (int) $this->input->get('language');
|
||||||
if($id) $language = $this->languages->get($id);
|
if($id) $language = $this->languages->get($id);
|
||||||
|
|
||||||
// if language is not specified as a GET variable, then use the user's language
|
// if language is not specified as a GET variable, then use the user's language
|
||||||
@@ -85,7 +85,9 @@ class LanguageTabs extends WireData implements Module, ConfigurableModule {
|
|||||||
$this->wire('modules')->loadModuleFileAssets($this);
|
$this->wire('modules')->loadModuleFileAssets($this);
|
||||||
$this->wire('modules')->get('JqueryCore')->use('longclick');
|
$this->wire('modules')->get('JqueryCore')->use('longclick');
|
||||||
if(strpos($e->return, 'LanguageSupport') === false) return;
|
if(strpos($e->return, 'LanguageSupport') === false) return;
|
||||||
$id = $e->object->attr('id');
|
/** @var InputfieldForm $form */
|
||||||
|
$form = $e->object;
|
||||||
|
$id = $form->attr('id');
|
||||||
$e->return .= "<script>setupLanguageTabs($('#$id'));</script>";
|
$e->return .= "<script>setupLanguageTabs($('#$id'));</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +119,7 @@ class LanguageTabs extends WireData implements Module, ConfigurableModule {
|
|||||||
}
|
}
|
||||||
$id = $inputfield->attr('id');
|
$id = $inputfield->attr('id');
|
||||||
$liClass = trim($liClass);
|
$liClass = trim($liClass);
|
||||||
|
/** @noinspection HtmlUnknownAnchorTarget */
|
||||||
$this->tabs[] = "<li class='$liClass'><a data-lang='$language->id' class='$class' href='#langTab_$id'>$title</a></li>";
|
$this->tabs[] = "<li class='$liClass'><a data-lang='$language->id' class='$class' href='#langTab_$id'>$title</a></li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +130,7 @@ class LanguageTabs extends WireData implements Module, ConfigurableModule {
|
|||||||
* This method automatically calls resetTabs() after rendering.
|
* This method automatically calls resetTabs() after rendering.
|
||||||
*
|
*
|
||||||
* @param Inputfield $inputfield
|
* @param Inputfield $inputfield
|
||||||
* @param $content Content that will have the tabs
|
* @param string $content Content that will have the tabs
|
||||||
* @return string Modified $content with tabs
|
* @return string Modified $content with tabs
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user