src/articles/classes/Entity/Article.php
public function createPreviewFromText()
    {
        $preview = $this->text;
        $preview = trim(preg_replace('/<.+>/Us', ' ', $preview));
        $preview = str_replace(array("\n", "\r"), ' ', $preview);
        $preview = preg_replace('/\s{2,}/U', ' ', $preview);

        /** @var Articles $plugin */
        $plugin = $this->getTable()->getPlugin();
        $settings = $plugin->settings;
        if (!$settings['previewMaxSize'])
        {
            $settings['previewMaxSize'] = 500;
        }

        if ($settings['previewSmartSplit'])
        {
            preg_match("/\A(.{1," . $settings['previewMaxSize'] .
                "})(\.\s|\.|\Z)/Us", $preview, $result);
            $preview = $result[1];
        }
        else
        {
            $preview = mb_substr($preview, 0, $settings['previewMaxSize']);
        }
        if (mb_strlen($preview) < mb_strlen($this->text))
        {
            $preview .= '…';
        }
        $this->preview = strval($preview);
    }
public function createPreviewFromText()
    {
        $preview = $this->text;
        $preview = trim(preg_replace('/<.+>/Us', ' ', $preview));
        $preview = str_replace(array("\n", "\r"), ' ', $preview);
        $preview = preg_replace('/\s{2,}/U', ' ', $preview);

        /** @var Articles $plugin */
        $plugin = $this->getTable()->getPlugin();
        $settings = $plugin->settings;
        if (!$settings['previewMaxSize'])
        {
            $settings['previewMaxSize'] = 500;
        }

        if ($settings['previewSmartSplit'])
        {
            preg_match("/\A(.{1," . $settings['previewMaxSize'] .
                "})(\.\s|\.|\Z)/Us", $preview, $result);
            $preview = $result[1];
        }
        else
        {
            $preview = mb_substr($preview, 0, $settings['previewMaxSize']);
        }
        if (mb_strlen($preview) < mb_strlen($this->text))
        {
            $preview .= '…';
        }
        $this->preview = strval($preview);
    }
public function createPreviewFromText ( ) { $ preview = $ this -> text ; $ preview = trim ( preg_replace ( '/<.+>/Us' , ' ' , $ preview ) ) ; $ preview = str_replace ( array ( "\n" , "\r" ) , ' ' , $ preview ) ; $ preview = preg_replace ( '/\s{2,}/U' , ' ' , $ preview ) ; /** @var Articles $plugin */ $ plugin = $ this -> getTable ( ) -> getPlugin ( ) ; $ settings = $ plugin -> settings ; if ( ! $ settings [ 'previewMaxSize' ] ) { $ settings [ 'previewMaxSize' ] = 500 ; } if ( $ settings [ 'previewSmartSplit' ] ) { preg_match ( "/\A(.{1," . $ settings [ 'previewMaxSize' ] . "})(\.\s|\.|\Z)/Us" , $ preview , $ result ) ; $ preview = $ result [ 1 ] ; } else { $ preview = mb_substr ( $ preview , 0 , $ settings [ 'previewMaxSize' ] ) ; } if ( mb_strlen ( $ preview ) < mb_strlen ( $ this -> text ) ) { $ preview .= '…'; } $ this -> preview = strval ( $ preview ) ; }
Автоматически заполняет свойство $preview на основе свойства $text

@since 3.01
Автоматически заполняет свойство $preview на основе свойства $text