Last active
March 20, 2019 11:36
-
-
Save akool/3258e9b12bb1e750ffbb5155e32ae8d0 to your computer and use it in GitHub Desktop.
Плагин для скрытия и переименования полей веб-пользователей в админ-панели Evolution CMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //<?php | |
| /** | |
| * ManageUserFields | |
| * Плагин для скрытия и переименования полей веб-пользователей в админ-панели | |
| * | |
| * @category plugin | |
| * @version 0.2 | |
| * @author Akool | |
| * @internal @properties &hideFields=Скрываем;text; &renameFields=Переименовываем;text; | |
| * @internal @events OnWUsrFormRender | |
| * @internal @modx_category Manager and Admin | |
| * | |
| * Exemple config: &hideFields=Скрываем;text;phone,mobilephone,zip,country,dob,gender &renameFields=Переименовываем;textarea;state||Регион:,comment||Контакты: | |
| * | |
| * Important: Evolution CMS Database fields length limits: | |
| * phone: 100, mobilephone: 100, dob: int(10), gender: int(1), country: 25, zip: 25, state: 25, fax: 100, | |
| */ | |
| $hideFields = isset($hideFields) ? explode(',', $hideFields) : []; | |
| $renameFields = isset($renameFields) ? explode(',', $renameFields) : []; | |
| $output = ''; | |
| $hideFieldsSrt = ''; | |
| $renameFieldsSrt = ''; | |
| $e = &$modx->event; | |
| if ($e->name == 'OnWUsrFormRender') { | |
| if (count($hideFields)>0) { | |
| foreach ($hideFields as $field){ | |
| $hideFieldsSrt .= "document.querySelector('[name=".trim($field)."]').parentNode.parentNode.style.display = 'none';".PHP_EOL; | |
| } | |
| } | |
| if (count($renameFields)>0) { | |
| foreach ($renameFields as $field){ | |
| $val = explode('||', $field); | |
| $renameFieldsSrt .= "document.querySelector('[name=".trim($val[0])."]').parentNode.parentNode.children[0].innerHTML='". $val[1] . "';".PHP_EOL; | |
| } | |
| } | |
| if ('' != $hideFieldsSrt || '' != $renameFieldsSrt) { | |
| $output = " | |
| <!-- ManageUserFields plugin --> | |
| <script type=\"text/javascript\"> | |
| ".$hideFieldsSrt." | |
| ".$renameFieldsSrt." | |
| </script>"; | |
| } | |
| } | |
| $e->addOutput($output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment