Documentation

convert

string
convert(
 string text,
 bool   bPreview = true,
 array  arImages = array(),
 array  arAllow = array("HTML" =>   "N", 
                        "ANCHOR" => "Y", 
                        "BIU" =>    "Y", 
                        "IMG" =>    "Y", 
                        "QUOTE" =>  "Y", 
                        "CODE" =>   "Y", 
                        "FONT" =>   "Y", 
                        "LIST" =>   "Y", 
                        "SMILES" => "Y", 
                        "NL2BR" =>  "N")
);

The method formats the text according to bPreview, arImages, arAllow parameters. Non-static method.

Method parameters

ParameterDescription Available from version
text Blog post original text.
bPreview Flag - determines, whether to cut the text for viewing (per [CUT] tag).
Optional. By default true - the text will be cropped to [CUT] tag.
arImages Array of the array(array(IMAGE_ID, FILE_ID)[, ...]) type.
  • IMAGE_ID - image ID within the blog post;
  • FILE_ID - image file ID.
Optional. By default, image tags will not replaced.
arAllow Array of blog post formatting parameters. Optional parameter. The following parameters are available:
  • HTML - any HTML-tags can be included into the text
  • ANCHOR - permitted tag<a>;
  • BIU - permitted tag <b>, <i>, <u>;
  • IMG - permitted tag <img>;
  • QUOTE - permitted quote tag <quote>;
  • CODE - tag to display code is permitted <code>;
  • FONT - permitted tag <font>;
  • LIST - permitted tags <ul>, <li>;
  • SMILES - smileys display as images;
  • NL2BR - replace carriage breaks with the <br> tag with permission to receive any HTML tags;
  • VIDEO;
  • TABLE;
  • CUT_ANCHOR;
  • SHORT_ANCHOR.
Parameters can have the following values: Y and N.
type Optional parameter. Value by default - "html". Deleted from 10.0.0 onwards
arParams Optional parameter.

Returned value

The method returns formatted blog post.

Examples of use

<?
$arPost = CBlogPost::GetByID(3);
$p = new blogTextParser();

$res = CBlogImage::GetList(array("ID"=>"ASC"),
                           array("POST_ID"=>$arPost['ID'], 
                           "BLOG_ID"=>$arPost['BLOG_ID']));
while ($arImage = $res->Fetch())
    $arImages[$arImage['ID']] = $arImage['FILE_ID'];

$text = $p->convert($arPost["DETAIL_TEXT"], false, $arImages);
?>


© «Bitrix24», 2001-2024
Up