Example #1
0
 private function getJevix($is_auto_br, $build_redirect_link)
 {
     cmsCore::loadLib('jevix.class', 'Jevix');
     $jevix = new Jevix();
     // Устанавливаем разрешённые теги. (Все не разрешенные теги считаются запрещенными.)
     $jevix->cfgAllowTags(array('p', 'br', 'span', 'div', 'a', 'img', 'b', 'i', 'u', 's', 'del', 'em', 'strong', 'sup', 'sub', 'hr', 'font', 'ul', 'ol', 'li', 'table', 'tbody', 'thead', 'tfoot', 'tr', 'td', 'th', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'code', 'blockquote', 'video', 'audio', 'youtube', 'facebook', 'object', 'param', 'embed', 'iframe'));
     // Устанавливаем коротие теги. (не имеющие закрывающего тега)
     $jevix->cfgSetTagShort(array('br', 'img', 'hr', 'embed'));
     // Устанавливаем преформатированные теги. (в них все будет заменятся на HTML сущности)
     $jevix->cfgSetTagPreformatted(array('pre', 'video'));
     // Устанавливаем теги, которые необходимо вырезать из текста вместе с контентом.
     $jevix->cfgSetTagCutWithContent(array('script', 'style', 'meta'));
     $jevix->cfgSetTagIsEmpty(array('param', 'embed', 'a', 'iframe', 'div'));
     // Устанавливаем разрешённые параметры тегов. Также можно устанавливать допустимые значения этих параметров.
     $jevix->cfgAllowTagParams('a', array('href' => '#link', 'name' => '#text', 'target' => '#text', 'class' => '#text'));
     $jevix->cfgAllowTagParams('img', array('src', 'style' => '#text', 'alt' => '#text', 'title' => '#text', 'align' => array('right', 'left', 'center'), 'width' => '#int', 'height' => '#int', 'hspace' => '#int', 'vspace' => '#int', 'class' => '#text'));
     $jevix->cfgAllowTagParams('span', array('style' => '#text'));
     $jevix->cfgAllowTagParams('object', array('width' => '#int', 'height' => '#int', 'data' => array('#domain' => array('youtube.com', 'rutube.ru', 'vimeo.com', 'vk.com')), 'type' => '#text'));
     $jevix->cfgAllowTagParams('param', array('name' => '#text', 'value' => '#text'));
     $jevix->cfgAllowTagParams('embed', array('src' => array('#domain' => array('youtube.com', 'rutube.ru', 'vimeo.com', 'vk.com')), 'type' => '#text', 'allowscriptaccess' => '#text', 'allowfullscreen' => '#text', 'width' => '#int', 'height' => '#int', 'flashvars' => '#text', 'wmode' => '#text'));
     $jevix->cfgAllowTagParams('iframe', array('width' => '#int', 'height' => '#int', 'style' => '#text', 'frameborder' => '#int', 'allowfullscreen' => '#text', 'src' => array('#domain' => array('youtube.com', 'rutube.ru', 'vimeo.com', 'vk.com', 'my.mail.ru', 'facebook.com'))));
     $jevix->cfgAllowTagParams('table', array('width' => '#int', 'height' => '#int', 'cellpadding' => '#int', 'cellspacing' => '#int', 'border' => '#int', 'style' => '#text', 'align' => '#text', 'valign' => '#text'));
     $jevix->cfgAllowTagParams('td', array('width' => '#int', 'height' => '#int', 'style' => '#text', 'align' => '#text', 'valign' => '#text', 'colspan' => '#int', 'rowspan' => '#int'));
     $jevix->cfgAllowTagParams('th', array('width' => '#int', 'height' => '#int', 'style' => '#text', 'align' => '#text', 'valign' => '#text', 'colspan' => '#int', 'rowspan' => '#int'));
     $jevix->cfgAllowTagParams('p', array('style' => '#text'));
     $jevix->cfgAllowTagParams('div', array('style' => '#text', 'class' => '#text'));
     // Устанавливаем параметры тегов являющиеся обязательными. Без них вырезает тег оставляя содержимое.
     $jevix->cfgSetTagParamsRequired('img', 'src');
     $jevix->cfgSetTagParamsRequired('a', 'href');
     // Устанавливаем теги которые может содержать тег контейнер
     $jevix->cfgSetTagChilds('ul', array('li'), false, true);
     $jevix->cfgSetTagChilds('ol', array('li'), false, true);
     $jevix->cfgSetTagChilds('table', array('tr', 'tbody', 'thead', 'tfoot', 'th', 'td'), false, true);
     $jevix->cfgSetTagChilds('tbody', array('tr', 'td', 'th'), false, true);
     $jevix->cfgSetTagChilds('thead', array('tr', 'td', 'th'), false, true);
     $jevix->cfgSetTagChilds('tfoot', array('tr', 'td', 'th'), false, true);
     $jevix->cfgSetTagChilds('tr', array('td'), false, true);
     $jevix->cfgSetTagChilds('tr', array('th'), false, true);
     // Устанавливаем автозамену
     $jevix->cfgSetAutoReplace(array('+/-', '(c)', '(с)', '(r)', '(C)', '(С)', '(R)'), array('±', '©', '©', '®', '©', '©', '®'));
     // включаем режим замены переноса строк на тег <br/>
     $jevix->cfgSetAutoBrMode($is_auto_br);
     // включаем режим автоматического определения ссылок
     $jevix->cfgSetAutoLinkMode(true);
     // если нужно обрабатывать внешние ссылки в редирект
     if ($build_redirect_link) {
         $jevix->cfgSetTagCallbackFull('a', array($this, 'linkRedirectPrefix'));
     }
     // Отключаем типографирование в определенном теге
     $jevix->cfgSetTagNoTypography('pre', 'youtube', 'iframe');
     // Ставим колбэк для youtube
     $jevix->cfgSetTagCallbackFull('youtube', array($this, 'parseYouTubeVideo'));
     // Ставим колбэк для facebook
     $jevix->cfgSetTagCallbackFull('facebook', array($this, 'parseFacebookVideo'));
     // Ставим колбэк на iframe
     $jevix->cfgSetTagCallbackFull('iframe', array($this, 'parseIframe'));
     // Ставим колбэк для кода
     $jevix->cfgSetTagCallback('code', array($this, 'parseCode'));
     return $jevix;
 }
Example #2
0
 /**
  * Конфигурирует типограф
  *
  */
 protected function JevixConfig()
 {
     // разрешаем в параметрах символ &
     unset($this->oJevix->entities1['&']);
     // Разрешённые теги
     $this->oJevix->cfgAllowTags(array('cut', 'a', 'img', 'i', 'b', 'u', 's', 'video', 'em', 'strong', 'nobr', 'li', 'ol', 'ul', 'sup', 'abbr', 'sub', 'acronym', 'h4', 'h5', 'h6', 'br', 'hr', 'pre', 'code', 'object', 'param', 'embed', 'blockquote'));
     // Коротие теги типа
     $this->oJevix->cfgSetTagShort(array('br', 'img', 'hr', 'cut'));
     // Преформатированные теги
     $this->oJevix->cfgSetTagPreformatted(array('pre', 'code', 'video'));
     // Разрешённые параметры тегов
     $this->oJevix->cfgAllowTagParams('img', array('src', 'alt' => '#text', 'title', 'align' => array('right', 'left', 'center'), 'width' => '#int', 'height' => '#int', 'hspace' => '#int', 'vspace' => '#int'));
     $this->oJevix->cfgAllowTagParams('a', array('title', 'href', 'rel'));
     $this->oJevix->cfgAllowTagParams('cut', array('name'));
     $this->oJevix->cfgAllowTagParams('object', array('width' => '#int', 'height' => '#int', 'data' => '#link', 'type' => '#text'));
     $this->oJevix->cfgAllowTagParams('param', array('name' => '#text', 'value' => '#text'));
     $this->oJevix->cfgAllowTagParams('embed', array('src' => '#image', 'type' => '#text', 'allowscriptaccess' => '#text', 'allowfullscreen' => '#text', 'width' => '#int', 'height' => '#int', 'flashvars' => '#text', 'wmode' => '#text'));
     // Параметры тегов являющиеся обязательными
     $this->oJevix->cfgSetTagParamsRequired('img', 'src');
     $this->oJevix->cfgSetTagParamsRequired('a', 'href');
     // Теги которые необходимо вырезать из текста вместе с контентом
     $this->oJevix->cfgSetTagCutWithContent(array('script', 'iframe', 'style'));
     // Вложенные теги
     $this->oJevix->cfgSetTagChilds('ul', array('li'), false, true);
     $this->oJevix->cfgSetTagChilds('ol', array('li'), false, true);
     $this->oJevix->cfgSetTagChilds('object', 'param', false, true);
     $this->oJevix->cfgSetTagChilds('object', 'embed', false, false);
     // Если нужно оставлять пустые не короткие теги
     $this->oJevix->cfgSetTagIsEmpty(array('param', 'embed'));
     // Не нужна авто-расстановка <br>
     $this->oJevix->cfgSetTagNoAutoBr(array('ul', 'ol', 'object'));
     // Теги с обязательными параметрами
     $this->oJevix->cfgSetTagParamDefault('embed', 'wmode', 'opaque', true);
     if (Config::Get('view.noindex')) {
         $this->oJevix->cfgSetTagParamDefault('a', 'rel', 'nofollow', true);
     }
     // Отключение авто-добавления <br>
     $this->oJevix->cfgSetAutoBrMode(true);
     // Автозамена
     $this->oJevix->cfgSetAutoReplace(array('+/-', '(c)', '(с)', '(r)', '(C)', '(С)', '(R)'), array('±', '©', '©', '®', '©', '©', '®'));
     //$this->oJevix->cfgSetXHTMLMode(false);
     $this->oJevix->cfgSetTagNoTypography('code');
     $this->oJevix->cfgSetTagNoTypography('video');
     $this->oJevix->cfgSetTagNoTypography('object');
     // Теги, после которых необходимо пропускать одну пробельную строку
     $this->oJevix->cfgSetTagBlockType(array('h4', 'h5', 'h6', 'ol', 'ul', 'blockquote', 'pre'));
 }
Example #3
0
 /**
  * Инициализация
  */
 public function Init()
 {
     $this->SetDefaultEvent('index');
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('search'));
     $this->nModeOutList = Config::Get('module.search.out_mode');
     $this->nShippetLength = Config::Get('module.search.snippet.length');
     $this->nShippetMaxLength = Config::Get('module.search.snippet.max_length');
     if ($this->nShippetMaxLength > 0 && $this->nShippetMaxLength < $this->nShippetLength) {
         $this->nShippetMaxLength = $this->nShippetLength;
     }
     $this->sSnippetBeforeMatch = Config::Get('module.search.snippet.before_match');
     $this->sSnippetAfterMatch = Config::Get('module.search.snippet.after_match');
     $this->sSnippetBeforeFragment = Config::Get('module.search.snippet.before_fragment');
     $this->sSnippetAfterFragment = Config::Get('module.search.snippet.after_fragment');
     $this->nSnippetMaxFragments = Config::Get('module.search.snippet.max_fragments');
     $this->sPatternW = Config::Get('module.search.char_pattern');
     $this->sPatternB = '[^' . mb_substr($this->sPatternW, 1);
     // '[^\wа-яА-Я\.\*-]';    // граница слова
     $this->sPatternX = '[^\\s' . mb_substr($this->sPatternW, 1);
     // '[^\s\wа-яА-Я\*-]';  // запрещеные символы без *
     $this->sPatternXA = '[^\\s\\*' . mb_substr($this->sPatternW, 1);
     // '[^\s\wа-яА-Я-]';               // запрещеные символы, в т.ч. *
     $this->bSearchStrict = Config::Get('module.search.strict_search');
     $this->bSkipAllTags = Config::Get('module.search.skip_all_tags');
     $this->nItemsPerPage = Config::Get('module.search.items_per_page');
     mb_internal_encoding('UTF-8');
     $this->oJevix = new Jevix();
     // Разрешённые теги
     if ($this->nModeOutList == 'snippet') {
         $this->oJevix->cfgAllowTags(array('a', 'img', 'object', 'param', 'embed'));
     } else {
         $this->oJevix->cfgAllowTags(array('a', 'img', 'object', 'param', 'embed'));
     }
     // Коротие теги типа
     $this->oJevix->cfgSetTagShort(array('img'));
     // Разрешённые параметры тегов
     $this->oJevix->cfgAllowTagParams('img', array('src', 'alt' => '#text', 'title', 'align' => array('right', 'left', 'center'), 'width' => '#int', 'height' => '#int', 'hspace' => '#int', 'vspace' => '#int'));
     $this->oJevix->cfgAllowTagParams('a', array('title', 'href', 'rel'));
     $this->oJevix->cfgAllowTagParams('object', array('width' => '#int', 'height' => '#int', 'data' => '#link'));
     $this->oJevix->cfgAllowTagParams('param', array('name' => '#text', 'value' => '#text'));
     $this->oJevix->cfgAllowTagParams('embed', array('src' => '#image', 'type' => '#text', 'allowscriptaccess' => '#text', 'allowfullscreen' => '#text', 'width' => '#int', 'height' => '#int', 'flashvars' => '#text', 'wmode' => '#text'));
     // Параметры тегов являющиеся обязательными
     $this->oJevix->cfgSetTagParamsRequired('img', 'src');
     $this->oJevix->cfgSetTagParamsRequired('a', 'href');
     // Теги которые необходимо вырезать из текста вместе с контентом
     $this->oJevix->cfgSetTagCutWithContent(array('script', 'iframe', 'style'));
     // Вложенные теги
     $this->oJevix->cfgSetTagChilds('object', 'param', false, true);
     $this->oJevix->cfgSetTagChilds('object', 'embed', false, false);
     // Отключение авто-добавления <br>
     $this->oJevix->cfgSetAutoBrMode(true);
     $this->SetTemplateAction('index');
 }