Jump to content
View in the app

A better way to browse. Learn more.

IPBMafia.ru - поддержка Invision Community, релизы, темы, плагины и приложения

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Функция удаления

Featured Replies

Posted

какая функция удаляет например ipsSpoiler из контента на страницах профиля, поиска и т.д.? Либо я туплю, но функция public static function removeElements в IPS\Text\Parser ничего не удаляет

Движок указанной функцией обрезает теги, например здесь system/Content/Search/Index

/* Strip spoilers */
		$content = $object->searchIndexContent();
		if ( preg_match( '#<div\s+?class=["\']ipsSpoiler["\']#', $content ) )
		{
			$content = \IPS\Text\Parser::removeElements( $content, array( 'div[class=ipsSpoiler]' ) );
		}
		
		/* Take the HTML out of the content */
		$content = trim( str_replace( \chr(0xC2) . \chr(0xA0), ' ', strip_tags( preg_replace( "/(<br(?: \/)?>|<\/p>)/i", ' ', preg_replace( "#<blockquote(?:[^>]+?)>.+?(?<!<blockquote)</blockquote>#s", " ", preg_replace( "#<script(.*?)>(.*)</script>#uis", "", ' ' . $content . ' ' ) ) ) ) ) );

 

  • Author
3 минуты назад, Respected сказал:

Движок указанной функцией обрезает теги, например здесь system/Content/Search/Index


/* Strip spoilers */
		$content = $object->searchIndexContent();
		if ( preg_match( '#<div\s+?class=["\']ipsSpoiler["\']#', $content ) )
		{
			$content = \IPS\Text\Parser::removeElements( $content, array( 'div[class=ipsSpoiler]' ) );
		}
		
		/* Take the HTML out of the content */
		$content = trim( str_replace( \chr(0xC2) . \chr(0xA0), ' ', strip_tags( preg_replace( "/(<br(?: \/)?>|<\/p>)/i", ' ', preg_replace( "#<blockquote(?:[^>]+?)>.+?(?<!<blockquote)</blockquote>#s", " ", preg_replace( "#<script(.*?)>(.*)</script>#uis", "", ' ' . $content . ' ' ) ) ) ) ) );

 

тогда какой он удаляет то, что находится в ipsSpoiler ?

  • Author
3 часа назад, Respected сказал:

Так этой строкой и удаляет 


$content = \IPS\Text\Parser::removeElements( $content, array( 'div[class=ipsSpoiler]' ) );

 

что-то у меня локальный сервер развалился, контент не обновлялся и хук не срабатывал, а так все работает правильно.

  • Author
/**
	 * Remove specific elements, useful for cleaning up content for display or truncating
	 *
	 * @param	string				$value			The value to parse
	 * @param	array|string		$elements		Element to remove, or array of elements to remove. Can be in format "element[attribute=value]"
	 * @return	string
	 */
	public static function removeElements( $value, $elements=array( 'blockquote', 'img', 'a' ) )
	{
		array_push($elements, 'div[class=my_spoiler]');
		return parent::removeElements( $value, $elements );
	}

я попробовал добавить элемент глобально, он удаляет его в приложении страниц (главная страница со списком статей), но не удаляет в профиле, страниц с результатами поиска и т.д.

  • Author

Через truncated тоже удаляет только в приложении страниц

/**
	 * Removes HTML and optionally truncates content
	 *
	 * @param	bool		$oneLine	If TRUE, will use spaces instead of line breaks. Useful if using a single line display.
	 * @param	int|null	$length		If supplied, and $oneLine is set to TRUE, the returned content will be truncated to this length
	 * @return	string
	 * @note	For now we are removing all HTML. If we decide to change this to remove specific tags in future, we can use \IPS\Text\Parser::removeElements( $this->content() )
	 */
	static public function truncate( $content, $oneLine=false, $length=500 )
	{
		$content = static::removeElements( $content, array( 'div[class=my_spoiler]' ) );
		return parent::truncate( $content, $oneLine, $length );
	}

у меня уже мозг плавится, не понимаю как удалить в профиле и т.д.

  • Author

я так понял это делается через public function indexData( \IPS\Content\Searchable $object ) в IPS\Content\Search\Index
как правильно захукать код, чтобы добавить в него \IPS\Text\Parser::removeElements( $content, array( 'div[class=my_spoiler]' ) );

?

  • Author
7 часов назад, WaNted сказал:

Глянь \IPS\Content\Search\Result::preDisplay

там вроде везде уже отформатированный текст выводит. Я нашел обходной путь, так как в public function indexData() вызывается searchIndexContent(), я просто в IPS\Content в эту функцию запилил \IPS\Text\Parser::removeElements( $content, array( 'div[class=my_spoiler]' ) );

  • Author

Не нашел рабочего хайда под новую версию ips, пришлось писать самому. Как вам идея хайда под ранг пользователя? Так как ранг пользователя гибок к настройкам, а пользователь сам решает какими путями его получить, думаю это самый топ вариант.
hide12.thumb.png.b7fc5dd5715643c3295aed5bd87851d5.png

  • 2 месяца спустя...
  • Author
38 минут назад, Dobrochas сказал:

ZIKURIK отличная идея. А есть уже рабочая версия?

Работает на одном из моих проектов который я запущу скорее всего на неделе. А так в паблике если и будет то будет платная версия

Еще реализовал чью-то идею, кто-то хотел спойлер с редактируемым заголовком. Второй спойлер кастомный:1326523337__2021-09-14_184900.thumb.png.f9e9cc78af536f87f19b420c8d5e65f8.png

  • 3 недели спустя...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Ответить в этой теме...

Последние посетители 0

  • No registered users viewing this page.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.