Vladimir
Как могут не удаляться символы переноса строк и пробелов? // Удаляем html теги, &nbsp;, &amp;, <script>, <iframe> и т.д. $article['title'] = OutputFilter::cleanText($article['title']); $article['description'] = OutputFilter::cleanText($article['description']); // Удаляем &nbsp; $article['title'] = str_replace("\xC2\xA0", ' ', $article['title']); $article['description'] = str_replace("\xC2\xA0", ' ', $article['description']); $article['title'] = str_replace(['\r\n','\r', '\n', '\t', PHP_EOL], ' ', $article['title']); while (str_contains($article['title'], ' ')) { $article['title'] = str_replace(' ', ' ', $article['title']); } $article['description'] = str_replace(['\r\n','\r', '\n', '\t', PHP_EOL], ' ', $article['description']); while (str_contains($article['description'], ' ')) { $article['description'] = str_replace(' ', ' ', $article['description']); } // Удаляем пробелы по краям $article = array_map('trim', $article); $article = array_map('trim', $article); Вот это должно удалять всё, но в итоговом тексте остаются переносы.
Проблема в том, что вы используете строки с одинарными кавычками для замены управляющих символов. В PHP строки в одинарных кавычках не интерпретируют escape-последовательности, поэтому '\r\n', '\r', '\n', '\t' ищутся как буквальные символы \, r, n и т.д. Вот исправленный код: // Удаляем html теги, &nbsp;, &amp;, <script>, <iframe> и т.д. $article['title'] = OutputFilter::cleanText($article['title']); $article['description'] = OutputFilter::cleanText($article['description']); // Удаляем &nbsp; $article['title'] = str_replace("\xC2\xA0", ' ', $article['title']); $article['description'] = str_replace("\xC2\xA0", ' ', $article['description']); // ИСПРАВЛЕНО: используем двойные кавычки для escape-последовательностей $article['title'] = str_replace(["\r\n", "\r", "\n", "\t", PHP_EOL], ' ', $article['title']); while (str_contains($article['title'], ' ')) { $article['title'] = str_replace(' ', ' ', $article['title']); } $article['description'] = str_replace(["\r\n", "\r", "\n", "\t", PHP_EOL], ' ', $article['description']); while (str_contains($article['description'], ' ')) { $article['description'] = str_replace(' ', ' ', $article['description']); } // Удаляем пробелы по краям $article = array_map('trim', $article); Ключевые изменения: · Заменил '\r\n' на "\r\n" · Заменил '\r' на "\r" · Заменил '\n' на "\n" · Заменил '\t' на "\t" Также можно использовать более эффективный подход с регулярными выражениями: // Альтернативный вариант с preg_replace $article['title'] = preg_replace('/\s+/', ' ', $article['title']); $article['description'] = preg_replace('/\s+/', ' ', $article['description']); // Удаляем пробелы по краям $article['title'] = trim($article['title']); $article['description'] = trim($article['description']); Регулярное выражение /\s+/ заменяет любую последовательность пробельных символов (пробелы, табы, переносы строк) на один пробел, что более эффективно.
Sergey
Не пытался qwen спросить ?
дипсик. Но я не кидал ему код.
Vladimir
дипсик. Но я не кидал ему код.
Ну вот выше ответ дипсик
Sergey
Проблема в том, что вы используете строки с одинарными кавычками для замены управляющих символов. В PHP строки в одинарных кавычках не интерпретируют escape-последовательности, поэтому '\r\n', '\r', '\n', '\t' ищутся как буквальные символы \, r, n и т.д. Вот исправленный код: // Удаляем html теги, &nbsp;, &amp;, <script>, <iframe> и т.д. $article['title'] = OutputFilter::cleanText($article['title']); $article['description'] = OutputFilter::cleanText($article['description']); // Удаляем &nbsp; $article['title'] = str_replace("\xC2\xA0", ' ', $article['title']); $article['description'] = str_replace("\xC2\xA0", ' ', $article['description']); // ИСПРАВЛЕНО: используем двойные кавычки для escape-последовательностей $article['title'] = str_replace(["\r\n", "\r", "\n", "\t", PHP_EOL], ' ', $article['title']); while (str_contains($article['title'], ' ')) { $article['title'] = str_replace(' ', ' ', $article['title']); } $article['description'] = str_replace(["\r\n", "\r", "\n", "\t", PHP_EOL], ' ', $article['description']); while (str_contains($article['description'], ' ')) { $article['description'] = str_replace(' ', ' ', $article['description']); } // Удаляем пробелы по краям $article = array_map('trim', $article); Ключевые изменения: · Заменил '\r\n' на "\r\n" · Заменил '\r' на "\r" · Заменил '\n' на "\n" · Заменил '\t' на "\t" Также можно использовать более эффективный подход с регулярными выражениями: // Альтернативный вариант с preg_replace $article['title'] = preg_replace('/\s+/', ' ', $article['title']); $article['description'] = preg_replace('/\s+/', ' ', $article['description']); // Удаляем пробелы по краям $article['title'] = trim($article['title']); $article['description'] = trim($article['description']); Регулярное выражение /\s+/ заменяет любую последовательность пробельных символов (пробелы, табы, переносы строк) на один пробел, что более эффективно.
Вот этого не знал. А привычки кидать всё что угодно в ии пока нет
Vladimir
Такая же тема кстати в bash
RINAT
Автоматизация с Joomla https://slides.woluweb.be/automation/
🅰️лександр | нержавеющая-мебель.рф
У меня какие-то баги в мониторе)
🅰️лександр | нержавеющая-мебель.рф
Касперский ничего не нашел)
Виталий
Касперского нашли зато, судя по снятому триллеру
🅰️лександр | нержавеющая-мебель.рф
Вот она жизнь за городом к чему приводит
Dan
Всем привет! Вопрос по Radical Multifield: есть два поля: Галерея (путь для файлов /images/gallery/ и Файлы (/attachments). После перехода на 5-ку все файлы загружаются по адресу указанному в Quantum Manager (images/gallery). Можно ли как-то настроить отдельный путь для файлов? Вроде бы в Quantum есть стандартные области, но как их прокинуть в настройки поля Radical Multifield я не нашёл.
Dmitriy
Коллеги, подскажите, никто не сталкивался с такой проблемой на Yootheme Pro и Joomla 5? Все последних версий. Не загружается окно со стилями, проблема уже на двух проектах
Dmitriy
Я туда обратно дергай. Иногда помогала и в сети кеш выключал.
Кеш отключен, а что имеется ввиду под туда-обратно дергать?
Дмитрий
под vpn попробуй
Dmitriy
может клаудфлар глючит, у них же вроде он стоит, нет?
Cloudflare не используется, под европейским VPN такая же проблема
Дмитрий
посмотри в консоли может там ошибка пишется при аякс запросе
Олег
Здравствуйте! Есть кто работал с Affiliate Tracker?
Dmitriy
а ключ стоит?
Да, ключ стоит, в консоли тишина…
Dmitriy
Дмитрий
Не помогает😞
на локалке или это в ДЦ каком-то?
Dmitriy
В ДЦ, Selectel
Igor
Не помогает😞
Попробуй алекса тогда в профильном чате помучать
Dan
галерея и квантум последних версий?
Добрый день! Да — 3.2.1 / 3.3.0
Dmitriy
Попробуй алекса тогда в профильном чате помучать
Да, похоже пора, тоже уже никаких идей нет
Дмитрий
Добрый день! Да — 3.2.1 / 3.3.0
скиньте скрины настройек полей мне в ЛС
Дмитрий
покручу на локалке у себя
Mitriy
Присоединяйся к чату по ссылке: https://max.ru/join/L5hwshmwNCHGKKioFwZ9uleQhwLwCBW_IPY7G283v8o
🅰️лександр | нержавеющая-мебель.рф
Sergey
### Getting $input from the Application, underlying problem There has been some messages about using getInput() to get the protected $input property of the Application object. However, there is a deeper problem. The need for this variable is an indication something is architecturally not completely correct in Joomla. Especially using this input in a model should not be necessary at all if we properly use the MVC pattern and dependency injection. A Model in Joomla should not be aware of (= dependent on) the input from the HTTP request. It is the responsability of the Controller to get that kind of info from outside the MVC triad and give it to the Model if necessary. Dependencies should be injected, not "conjured up" somewhere in an object, like is done now with `$app = Factory::getApplication();`. And if we only use that Application object to get the $input property (the HTTP request variables), then we should not inject the whole Application object, but only an Input object. Dependency injection makes the object in which that Input is injected testable: you can simply inject a test Input object. And you can also use that object with other Input than the HTTP request variables, for instance for [HMVC](https://en.wikipedia.org/wiki/Hierarchical_model%E2%80%93view%E2%80%93controller) (Hierarchical MVC, where you call another triad from within some MVC triad, for dispaying multiple sub-objects). A Controller should set the state of a Model. BUT in a Joomla ListModel we have a protected `populateState()` method, that (as you can read in its docblock) is a "method to auto-populate the model state". We do the same in the `getUserStateFromRequest()` method. We have that construction already for a very long time in Joomla. To keep using these methods without hard dependency on the Application $input property you'd have to inject an Input object when instantiating this ListModel. In the long run we should strive for not needing the Application object at all further down in the component's details. We've had discussions before to get rid of that whole Factory with which we conjure up the Application object and the Dependency Injection Container (DIC) everywhere. [Global mutable state](https://dev.to/ericnormand/global-mutable-state) is an anti-pattern, as is this [misuse of the DIC as a Service Locator](https://faceira.com/patterns/avoid-service-locators/). A step in the right direction would be to inject an Input object in Controllers and in the ListModel. @Septdir @drekun @fictionlabs @tsymbalmitia читали?
Dmitry
Да, я уже писал, что это наравне с фабрикой повлияет на сайты
Dmitry
А это ещё дальше, походу вообще выкинуть инпут из приложения 🙂
Igor
Ну в какой нибудь joomla 7 велком
Sergey
А это ещё дальше, походу вообще выкинуть инпут из приложения 🙂
Там дальше по дискуссии написали, что в пакете фреймворка где-то добавили магический метод и поэтому по-прежнему можно получить.
Dmitry
Хорошо хоть в J6 магический метод добавили
Dmitry
Чтобы $input не падал
Dmitry
Но тут речь о том, чтобы выкинуть инпут из приложения
Igor
Модели вообще очень странные
Dmitry
getInput() походу не будет работать
Sergey
getInput() походу не будет работать
А какого фига на него перетаскивали последние 4 года? ))
Dmitry
Не знаю...
Igor
Речь про то что в Модели его быть не должно
RINAT
А какого фига на него перетаскивали последние 4 года? ))
Наверно чтобы сново разозлить разработчиков )
Igor
А какого фига на него перетаскивали последние 4 года? ))
Это кстати в какой ветке я им могу все выслать на счёт порулате стейт и моделей
Dmitry
Типа в приложении останется, но доставать оттуда в модели не надо 😂
RINAT
### Getting $input from the Application, underlying problem There has been some messages about using getInput() to get the protected $input property of the Application object. However, there is a deeper problem. The need for this variable is an indication something is architecturally not completely correct in Joomla. Especially using this input in a model should not be necessary at all if we properly use the MVC pattern and dependency injection. A Model in Joomla should not be aware of (= dependent on) the input from the HTTP request. It is the responsability of the Controller to get that kind of info from outside the MVC triad and give it to the Model if necessary. Dependencies should be injected, not "conjured up" somewhere in an object, like is done now with `$app = Factory::getApplication();`. And if we only use that Application object to get the $input property (the HTTP request variables), then we should not inject the whole Application object, but only an Input object. Dependency injection makes the object in which that Input is injected testable: you can simply inject a test Input object. And you can also use that object with other Input than the HTTP request variables, for instance for [HMVC](https://en.wikipedia.org/wiki/Hierarchical_model%E2%80%93view%E2%80%93controller) (Hierarchical MVC, where you call another triad from within some MVC triad, for dispaying multiple sub-objects). A Controller should set the state of a Model. BUT in a Joomla ListModel we have a protected `populateState()` method, that (as you can read in its docblock) is a "method to auto-populate the model state". We do the same in the `getUserStateFromRequest()` method. We have that construction already for a very long time in Joomla. To keep using these methods without hard dependency on the Application $input property you'd have to inject an Input object when instantiating this ListModel. In the long run we should strive for not needing the Application object at all further down in the component's details. We've had discussions before to get rid of that whole Factory with which we conjure up the Application object and the Dependency Injection Container (DIC) everywhere. [Global mutable state](https://dev.to/ericnormand/global-mutable-state) is an anti-pattern, as is this [misuse of the DIC as a Service Locator](https://faceira.com/patterns/avoid-service-locators/). A step in the right direction would be to inject an Input object in Controllers and in the ListModel. @Septdir @drekun @fictionlabs @tsymbalmitia читали?
а че Брайан говорить )
Igor
Сделаю кофе зайду. Он там даже верхушку айсберга не нашёл 😀
Eugene
gemini можно в России запустить? под vpn все равно: Gemini isn’t currently supported in your country. Stay tuned!
Igor
когда понял сколько запросов в бд будет если попытаться сохранить 1000 материалов с одним и тем же алисом.
Eugene
Куки очисттт
полностью очистил кукис, авторизовался заново. не помогло.
Eugene
Весь бразуер через VPN проброшен?
ты спросил страшную вещь. понятия не имею. стандартные настройки браузера
Igor
ты спросил страшную вещь. понятия не имею. стандартные настройки браузера
Я не про это. Я про то. Все ли стайты и стрипы у тебя получаются через VPN
Igor
А то тот же GPT чекает geo при получении скрипта с CDN
Eugene
Vladimir
gmail аккаунтом
в нем все дело
Eugene
а там разве можно иначе?
Vladimir
а там разве можно иначе?
история акаунта
Eugene
история акаунта
нужен свежий акк, зареганный под vpn из типа другой страны?
Дмитрий
### Getting $input from the Application, underlying problem There has been some messages about using getInput() to get the protected $input property of the Application object. However, there is a deeper problem. The need for this variable is an indication something is architecturally not completely correct in Joomla. Especially using this input in a model should not be necessary at all if we properly use the MVC pattern and dependency injection. A Model in Joomla should not be aware of (= dependent on) the input from the HTTP request. It is the responsability of the Controller to get that kind of info from outside the MVC triad and give it to the Model if necessary. Dependencies should be injected, not "conjured up" somewhere in an object, like is done now with `$app = Factory::getApplication();`. And if we only use that Application object to get the $input property (the HTTP request variables), then we should not inject the whole Application object, but only an Input object. Dependency injection makes the object in which that Input is injected testable: you can simply inject a test Input object. And you can also use that object with other Input than the HTTP request variables, for instance for [HMVC](https://en.wikipedia.org/wiki/Hierarchical_model%E2%80%93view%E2%80%93controller) (Hierarchical MVC, where you call another triad from within some MVC triad, for dispaying multiple sub-objects). A Controller should set the state of a Model. BUT in a Joomla ListModel we have a protected `populateState()` method, that (as you can read in its docblock) is a "method to auto-populate the model state". We do the same in the `getUserStateFromRequest()` method. We have that construction already for a very long time in Joomla. To keep using these methods without hard dependency on the Application $input property you'd have to inject an Input object when instantiating this ListModel. In the long run we should strive for not needing the Application object at all further down in the component's details. We've had discussions before to get rid of that whole Factory with which we conjure up the Application object and the Dependency Injection Container (DIC) everywhere. [Global mutable state](https://dev.to/ericnormand/global-mutable-state) is an anti-pattern, as is this [misuse of the DIC as a Service Locator](https://faceira.com/patterns/avoid-service-locators/). A step in the right direction would be to inject an Input object in Controllers and in the ListModel. @Septdir @drekun @fictionlabs @tsymbalmitia читали?
ну идея правильная как по мне, даже по идее контроллерв не должен знать откуда какой протокол. Но мне не нравится как они внедряют, они по сути делают мелкие изменения и которые ломают совместость со старым, просто в чем смысл? Сделайте сразу с нуля новое и все. зачем ломать по мелочи, и под нее подстраиваться
Дмитрий
бред полный